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

# Errors

> Understand End Close API error responses: the JSON error body, each HTTP status code the API returns, and which errors are safe to retry.

The End Close API uses standard HTTP status codes: `2xx` for success, `4xx` when something about the request needs to change, and `5xx` when End Close failed to handle it. Client errors return a JSON body with a human-readable `message`.

## Error response body

```json 422 Unprocessable Entity theme={"dark"}
{
  "message": "Invalid currency 'US'. Must be a 3-letter ISO 4217 code"
}
```

**message** `string` *required*

What went wrong, written for a developer. Log it, but don't parse it: the wording can change.

A few errors add context next to `message`. A `409` from `POST /reconciliations/{id}/run` includes `run`, the run already in progress, so you can poll it instead of starting another.

## Status codes

| Status | Meaning | Common causes |
| - | - | - |
| `200 OK` | Success | Reads and most updates. |
| `201 Created` | A resource was created | `POST` to a create endpoint. |
| `202 Accepted` | Accepted for asynchronous processing | `POST /records/bulk`. Poll `GET /bulk_requests/{id}` for the outcome. |
| `204 No Content` | Success with no body | Some deletes. |
| `400 Bad Request` | A parameter has an unsupported value | An invalid `on_conflict` on `POST /records/bulk`. |
| `401 Unauthorized` | No valid API key | Missing `X-API-Key` header, or a key that doesn't exist. See [Authentication](https://endclose.com/docs/api-reference/authentication.md). |
| `403 Forbidden` | The key can't call this endpoint | Agent management with a key other than the environment's API key. |
| `404 Not Found` | The resource or path doesn't exist in this environment | A wrong ID, an ID from the other environment, or an unknown endpoint. |
| `409 Conflict` | The request clashes with the resource's current state | Changing or deleting a record that's already reconciled, cancelling a bulk request that has finished, starting a run while one is in progress, deleting a data stream that reconciliations use, or reusing an [idempotency key](https://endclose.com/docs/api-reference/idempotency.md) while its first request is still running. |
| `422 Unprocessable Entity` | The request is well formed but invalid | Missing required fields, a validation failure, a duplicate, `GET /records` without a filter, more than 1,000 items in a bulk call, or an idempotency key reused for a different request. |
| `5xx` | End Close couldn't complete the request | An unexpected server error. |

Each endpoint page in the API reference lists the statuses it can return and why.

> [!NOTE]
>
> An ID from your Sandbox environment returns `404` when you call the API with your Production key, and the reverse. Check which key you're using before assuming a resource is missing.

## Partial failures

Some endpoints succeed overall while individual items fail:

* `POST /records/bulk` validates and inserts each record on its own. Read per-record failures from `GET /bulk_requests/{id}`.
* `PUT /reconciliation_exceptions/{id}/findings` and `PUT /reconciliations/{reconciliation_id}/data_streams/{data_stream_id}/findings` return `200` with an `upserted` count and an `errors` list for the findings that weren't written.

Check those fields as well as the status code.

## When to retry

| Response | Retry? |
| - | - |
| Network error or timeout | Yes, with the same `Idempotency-Key` where the endpoint accepts one. |
| `5xx` | Yes, with exponential backoff and the same `Idempotency-Key`. |
| `409` from an idempotency key still in progress | Yes, after a short wait, with the same key. |
| `409` from a run already in progress | No. Poll the `run` in the response body. |
| Other `409` | No. The resource's state has to change first. |
| `400`, `401`, `403`, `404`, `422` | No. Fix the request, key or ID, then send it again. |

Retrying a write without an `Idempotency-Key` can apply it twice. See [Idempotency](https://endclose.com/docs/api-reference/idempotency.md) for the endpoints that accept one.

## FAQ

> [accordion] Why do I get 404 for an ID I can see in the app?
>
> API keys are scoped to one environment. The app may be showing Sandbox while your request uses the Production key, or the reverse.

> [accordion] Why does GET /records return 422?
>
> `GET /records` needs at least one of `data_stream_key`, `reconciliation_match_id`, `reconciliation_id`, `external_id` or `import_id`. It also returns `422` for an invalid `status`, `created_after` or `created_before`.

> [accordion] Why can't I update or delete a record?
>
> A record that's already reconciled, or that came from a file import or bulk request, can't be changed and returns `409`. Records you created one at a time with `POST /records` can be changed until they're reconciled.

## Related

> [card] [Idempotency](https://endclose.com/docs/api-reference/idempotency.md)
>
> Retry writes without applying them twice.

> [card] [Authentication](https://endclose.com/docs/api-reference/authentication.md)
>
> Send your API key with each request.


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