> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Error Summary

> See a validated import's blocking errors by family, with the values their cells hold, to fix each kind at once

[← Imports](https://code.dcycle.io/api-reference/imports/overview.md)

A file with many errors usually has few kinds of them: the same unknown fuel on 60 rows, the same column left blank.
This endpoint groups a validated session's blocking errors by family, the reason they happened and the way they are
fixed, so you can fix each kind once instead of cell by cell. Read it after [Validate](https://code.dcycle.io/api-reference/imports/validate.md)
and after each correction or delete.

Each family holds one group per rule and column, with the values the group's cells hold. To fix a group:

* Set a value on every row holding one of them: [Patch Rows](https://code.dcycle.io/api-reference/imports/patch-rows.md) with
  `match.filters` set to `{"<column_key>": ["<value>"]}` and `match.error` set to the group's rule and column.
* Fill its blank cells: `match.error` alone (no `filters` entry selects a blank).
* Leave its rows out: [Delete Rows](https://code.dcycle.io/api-reference/imports/delete-rows.md) with the same `match`.

Warnings are not listed: they don't block the submit.

## Request

### Headers

**x-api-key** `string` *required*

Your API key for authentication

**Example:** `sk_live_1234567890abcdef`

**x-organization-id** `string` *required*

Your organization UUID

**Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`

### Path Parameters

**import\_id** `string` *required*

UUID of the import session

**Example:** `"11111111-1111-1111-1111-111111111111"`

## Response

**import\_id** `string`

UUID of the import session

**error\_rows** `integer`

Rows with at least one blocking error

**families** `array`

One entry per family with errors, the one with the most rows first.

**properties**

**family** `string`

Why the errors happened, by how they are fixed:

* `unrecognized_value`: the value isn't one Dcycle knows (a fuel, a facility, a LER code). Pick one of the column's options.
* `missing_value`: a cell the row needs is blank.
* `invalid_format`: the value can't be read as what the column takes (a number, a date, an email), or reads two ways.
* `incompatible_combination`: each value is valid, but not together with another column of the row (diesel in kWh).
* `out_of_range`: the value is past a limit (negative, in the future, over 100 %, too long).
* `duplicate`: the record repeats one in the file, or one Dcycle already has.
* `outside_organization`: the record belongs to an organization you can't import into.
* `emission_factor`: the custom emission factor doesn't exist or doesn't fit the row.
* `incomplete_block`: rows that go together (the legs of a shipment, a survey's answers) don't add up.
* `other`: none of the above.

**row\_count** `integer`

Rows with at least one error of the family

**groups** `array`

One group per rule and column, the most rows first.

**properties**

**rule** `string`

The validation rule, as the rows' errors name it

**column\_key** `string`

The template column the error is on

**row\_count** `integer`

Rows with this error

**values** `array`

The values the group's cells hold, the most frequent first, 50 at most.

**properties**

**value** `string | null`

The cell as Get Import Rows shows it, trimmed: the text a `match.filters` entry selects. `null` for a blank cell.

**row\_count** `integer`

Rows of the group holding it

**total\_values** `integer`

Distinct values the group holds, listed or not

## Example

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X GET "https://api.dcycle.io/v2/imports/11111111-1111-1111-1111-111111111111/error-summary" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}"
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import requests
import os

headers = {
    "x-api-key": os.getenv("DCYCLE_API_KEY"),
    "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
}

import_id = "11111111-1111-1111-1111-111111111111"
summary = requests.get(
    f"https://api.dcycle.io/v2/imports/{import_id}/error-summary",
    headers=headers,
).json()

# Every "Gasoleo A" with an unknown fuel becomes diesel, in one request.
requests.patch(
    f"https://api.dcycle.io/v2/imports/{import_id}/rows",
    headers=headers,
    json={
        "match": {
            "errors_only": True,
            "filters": {"fuel": ["Gasoleo A"]},
            "error": {"rule": "type_category", "column_key": "fuel"},
        },
        "values": {"fuel": "diesel"},
    },
)
```

```json Response theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "import_id": "11111111-1111-1111-1111-111111111111",
  "error_rows": 92,
  "families": [
    {
      "family": "unrecognized_value",
      "row_count": 62,
      "groups": [
        {
          "rule": "type_category",
          "column_key": "fuel",
          "row_count": 62,
          "values": [{"value": "Gasoleo A", "row_count": 62}],
          "total_values": 1
        }
      ]
    },
    {
      "family": "missing_value",
      "row_count": 30,
      "groups": [
        {
          "rule": "required",
          "column_key": "unit",
          "row_count": 30,
          "values": [{"value": null, "row_count": 30}],
          "total_values": 1
        }
      ]
    }
  ]
}
```

## Errors

### 409 Conflict

**Cause:** The session's rows are no longer stored.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"code": "IMPORT_SESSION_ARTIFACTS_UNAVAILABLE", "detail": "..."}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.