---
title: Get code coverage summary for a pull request
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Code Coverage
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Get code coverage summary for a pull request{% #get-code-coverage-summary-for-a-pull-request %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                                       |
| ----------------- | ------------------------------------------------------------------ |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/code-coverage/pr/summary |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/code-coverage/pr/summary |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/code-coverage/pr/summary      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/code-coverage/pr/summary      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/code-coverage/pr/summary  |
| uk1.datadoghq.com | POST https://api.uk1.datadoghq.com/api/v2/code-coverage/pr/summary |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/code-coverage/pr/summary     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/code-coverage/pr/summary |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/code-coverage/pr/summary |

### Overview

Retrieve aggregated code coverage statistics for a specific pull request in a repository. This endpoint provides overall coverage metrics as well as breakdowns by service and code owner. This endpoint requires the `code_coverage_read` permission.

OAuth apps require the `code_coverage_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#code-coverage) to access this endpoint.



### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                            | Type   | Description                                                                                                                                                             |
| ------------ | -------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]           | object | Data object for PR summary request.                                                                                                                                     |
| data         | attributes [*required*]     | object | Attributes for requesting code coverage summary for a pull request.                                                                                                     |
| attributes   | pr_number [*required*]      | int64  | The pull request number. Must be a positive integer.                                                                                                                    |
| attributes   | repository_url [*required*] | string | The repository URL. Accepts a full URL with or without a scheme (for example, `https://github.com/org/repo` or `github.com/org/repo`).                                  |
| data         | type [*required*]           | enum   | JSON:API type for PR coverage summary request. The value must always be `ci_app_coverage_pr_summary_request`. Allowed enum values: `ci_app_coverage_pr_summary_request` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "pr_number": 42,
      "repository_url": "https://github.com/datadog/shopist"
    },
    "type": "ci_app_coverage_pr_summary_request"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response object containing code coverage summary.

| Parent field         | Field                   | Type   | Description                                                                                                                                     |
| -------------------- | ----------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|                      | data                    | object | Data object for coverage summary response.                                                                                                      |
| data                 | attributes              | object | Attributes object for code coverage summary response.                                                                                           |
| attributes           | codeowners              | object | Coverage statistics broken down by code owner.                                                                                                  |
| additionalProperties | <any-key>               | object | Coverage statistics for a specific code owner.                                                                                                  |
| <any-key>            | evaluated_flags_count   | int64  | Number of coverage flags evaluated for the code owner.                                                                                          |
| <any-key>            | evaluated_reports_count | int64  | Number of coverage reports evaluated for the code owner.                                                                                        |
| <any-key>            | patch_coverage          | double | Patch coverage percentage for the code owner.                                                                                                   |
| <any-key>            | total_coverage          | double | Total coverage percentage for the code owner.                                                                                                   |
| attributes           | evaluated_flags_count   | int64  | Total number of coverage flags evaluated.                                                                                                       |
| attributes           | evaluated_reports_count | int64  | Total number of coverage reports evaluated.                                                                                                     |
| attributes           | patch_coverage          | double | Overall patch coverage percentage.                                                                                                              |
| attributes           | services                | object | Coverage statistics broken down by service.                                                                                                     |
| additionalProperties | <any-key>               | object | Coverage statistics for a specific service.                                                                                                     |
| <any-key>            | evaluated_flags_count   | int64  | Number of coverage flags evaluated for the service.                                                                                             |
| <any-key>            | evaluated_reports_count | int64  | Number of coverage reports evaluated for the service.                                                                                           |
| <any-key>            | patch_coverage          | double | Patch coverage percentage for the service.                                                                                                      |
| <any-key>            | total_coverage          | double | Total coverage percentage for the service.                                                                                                      |
| attributes           | total_coverage          | double | Overall total coverage percentage.                                                                                                              |
| data                 | id                      | string | Unique identifier for the coverage summary (base64-hashed).                                                                                     |
| data                 | type                    | enum   | JSON:API type for coverage summary response. The value must always be `ci_app_coverage_summary`. Allowed enum values: `ci_app_coverage_summary` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "codeowners": {
        "<any-key>": {
          "evaluated_flags_count": 2,
          "evaluated_reports_count": 4,
          "patch_coverage": 75.2,
          "total_coverage": 88.7
        }
      },
      "evaluated_flags_count": 8,
      "evaluated_reports_count": 12,
      "patch_coverage": 70.1,
      "services": {
        "<any-key>": {
          "evaluated_flags_count": 3,
          "evaluated_reports_count": 5,
          "patch_coverage": 72.3,
          "total_coverage": 85.5
        }
      },
      "total_coverage": 82.4
    },
    "id": "ZGQxMjM0NV9tYWluXzE3MDk1NjQwMDA=",
    "type": "ci_app_coverage_summary"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Not Authorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="500" %}
Internal server error
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/code-coverage/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "pr_number": 42,
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_pr_summary_request"
  }
}
EOF 
                
{% /tab %}
