الأخطاء ورموزها
One envelope, a stable code enum, and the exact set of statuses each operation can return.
Every failure returns the same JSON envelope, including validation failures. Parse the envelope rather than relying on the status code alone, and log request_id: it is the join key with support.
json
{
"error": {
"code": "quota_exceeded",
"message": "The organization has no funded credit left.",
"details": {},
"request_id": "req_01HX9Z6Q3M"
}
}Status codes
| Status | Meaning | Retry? |
|---|---|---|
| 400 | Malformed request or out-of-range value | No: fix the request |
| 401 | Credential missing, malformed or revoked | No |
| 403 | Credential valid but lacks the scope, or the origin is not allowed | No |
| 404 | Resource not found, or not visible to your organization | No |
| 409 | Conflict: idempotency key reused with a different payload, or a replay of an in-flight request | Reuse the original key |
| 413 | Payload or batch above the documented bound | No: split the request |
| 422 | A field failed validation | No |
| 429 | Rate or quota guard fired | Yes, after Retry-After |
| 500 | Unexpected server error | Yes with backoff, then report request_id |
| 503 | A dependency is temporarily unavailable | Yes, after Retry-After |
| 504 | An upstream provider timed out | Yes with backoff |
Error codes
Codes are stable identifiers. Branch on code, never on message text, which may be localised or reworded.
| Code | Typical status | What it means |
|---|---|---|
| invalid_request | 400 / 422 | A parameter or body field failed validation. details may name the field. |
| invalid_coordinates | 422 | A coordinate is outside the valid range, or latitude and longitude were swapped. |
| quota_exceeded | 429 | The organization has no funded credit, or the Free Sandbox allowance is exhausted. |
| rate_limited | 429 | An infrastructure protection ceiling was hit. Honour Retry-After. |
| idempotency_key_reuse | 409 | The same Idempotency-Key was sent with a different request. |
| idempotency_in_progress | 409 | An identical request with the same key is still running. Retry later; it will not be charged twice. |
| event_too_old | 422 | A tracking event's recorded_at is outside the accepted replay window. |
| event_too_far_future | 422 | A tracking event's recorded_at is ahead of server time beyond tolerance. |
| database_unavailable | 503 | A transient storage failure. Retry after the Retry-After header. |
| database_timeout | 504 | A storage operation timed out. |
| upstream_timeout | 504 | Routing or geocoding took too long. Retry, and consider a smaller request. |
Reading details
details is an object and its content depends on the code. For validation failures it may name the offending field. For quota failures it may report the balance state. Never assume a fixed shape: treat it as diagnostics, not as a contract you code against.
Retry policy
- Retry only 429, 500, 503 and 504, and only for idempotent requests or requests carrying an Idempotency-Key.
- Honour Retry-After when present. When absent, use exponential backoff with jitter, starting at 250 ms.
- Cap retries at two or three. A request that fails four times is a signal, not a transient.
- Never retry 401, 403, 404, 409, 413 or 422: the second attempt is guaranteed to fail the same way.
- Log request_id and the status code for every failed attempt so support can reconstruct the sequence.
