API errors
The problem documents the API returns, and how to retry safely.
Every error is a problem document (RFC 9457), with content type application/problem+json:
{
"type": "https://YOUR-CARE-CORE/docs/api-errors#validation_failed",
"title": "Unprocessable request",
"status": 422,
"code": "validation_failed",
"detail": "The request body has 2 problems.",
"errors": [
{ "field": "last_name", "message": "This field is required." },
{ "field": "date_of_birth", "message": "Must be a real date in the form YYYY-MM-DD." }
],
"request_id": "9f3c2a54b0e14c43"
}
- Branch on
code, which is stable.detailis for people and may be reworded. errorslists field-level problems where there are any (otherwise it is empty).- When a rule of the domain refuses a change (for example “Only current staff can be key workers”), the message is in
detail. The same text appears in the web interface. - A refused request changes nothing. Changes are all-or-nothing.
- Quote
request_idif you ask for help.
Codes
| Status | Code | Meaning and what to do |
|---|---|---|
| 400 | bad_request | The request itself is malformed: invalid JSON, a body that is not an object, a bad query parameter (limit, cursor, a date, an unknown kind…). Fix the request. |
| 401 | unauthorized | The key is missing, invalid, revoked or expired. Do not retry until you have a valid key. |
| 403 | forbidden | The key lacks the scope, or is not allowed from this address. The detail says which. |
| 403 | https_required | Use HTTPS. Never send a key over plain HTTP. |
| 404 | not_found | No such endpoint, or no such resource visible to this key (it may exist but be in another organisation, or need a scope the key lacks). The API does not reveal which. |
| 405 | method_not_allowed | Wrong method for that address. The Allow header lists the right ones. |
| 409 | request_in_progress | A request with that Idempotency-Key is still being processed. Wait for Retry-After, then repeat. |
| 415 | unsupported_media_type | Send Content-Type: application/json. |
| 422 | validation_failed | The request was understood but refused: a field is missing or wrong (see errors), or a rule of the domain forbids it (see detail). Change the request. Retrying unchanged will fail the same way. |
| 422 | idempotency_mismatch | That Idempotency-Key was already used for a different request. |
| 429 | rate_limited | Too many requests for this key. Wait Retry-After seconds. |
| 500 | internal_error | Our fault. Retry with the same Idempotency-Key after a short delay; if it persists, report the request_id. |
Retrying safely
- Retry on
429(afterRetry-After),500,502,503,504,409 request_in_progress, and network errors, with exponential back-off and a limit on attempts. - Always send an
Idempotency-KeyonPOSTso that a retry cannot do something twice. - Do not retry
400,401,403,404,405,415or422without changing something. GET,PATCHandDELETEare safe to retry (aDELETEof something already deleted may return a422).