# Error model Every error response has the same shape: ```json { "message": "Human-readable explanation." } ``` - The **HTTP status code** carries the semantics. - The **`message`** is a short human-readable string, suitable for logs and support tickets. It is **not** meant to be parsed by clients — its wording may change without a version bump. Discriminate on status code, not on message text. - **No internal detail leaks out.** Error responses never include stack traces, database driver names, third-party service names, or version numbers. If you need those for triage, contact support with the timestamp of the failing request — Gallantree's server-side logs have the detail. ## Status codes ### 2xx — success | Code | When | |------|------| | `200 OK` | Successful `GET`, `PUT`, or replay of an idempotent `POST` | | `201 Created` | Successful `POST` that created a resource | | `204 No Content` | Successful `DELETE`, or a successful action with no body | ### 4xx — you sent something the API cannot process | Code | When | Recovery | |------|------|----------| | `400 Bad Request` | Validation failed — a required field is missing, a value is the wrong type, or a bound is violated | Read the `message`, fix the request, resend | | `401 Unauthorized` | No API key, invalid key, or expired key | Re-check the key against the portal; regenerate if expired | | `403 Forbidden` | Key is valid but the request is not permitted — insufficient scopes, IP not in allowlist, or app suspended | Fix the scope in the portal, or fix the IP allowlist | | `404 Not Found` | The resource does not exist, or you do not have access to it | The API does not distinguish "doesn't exist" from "you can't see it" for privacy | | `409 Conflict` | An idempotency key has been reused with a different body; an `externalId` is already registered by a different integration source; or an app already has its maximum number of webhook subscriptions | Read the message; use a new idempotency key, fix the `externalId`, or delete a subscription you no longer need | | `429 Too Many Requests` | Rate limit exceeded | Honour `Retry-After`; see [Rate limits](rate-limits.md) | ### 5xx — the API broke | Code | When | Recovery | |------|------|----------| | `500 Internal Server Error` | Unexpected server failure | Log the timestamp, retry with back-off; if it persists, contact support with the timestamp | | `502 Bad Gateway` | Only from `POST /api/v1/webhooks/{webhookId}/test`: the test delivery to your endpoint failed. The body includes `httpStatus` (what your endpoint returned, if anything) and `responseTimeMs` | Check your endpoint is reachable and returns `2xx`, then send another test | | `503 Service Unavailable` | Upstream dependency temporarily unavailable, or the API is in maintenance | Retry with back-off; honour any `Retry-After` | ## Idempotency + errors If you retry a write request with the same `Idempotency-Key`, you'll get the **original response** — success or failure. The API does not re-attempt a failed write on replay; it returns the recorded outcome. If the original request produced a `500`, retrying with the same key returns the same `500`. Use a fresh key to actually retry the operation. See [Idempotency](idempotency.md). ## Recognising the same class of error programmatically Because the `message` may change wording, discriminate on **status code + endpoint**: ```typescript try { await client.createLoan(payload); } catch (err) { if (err.status === 429) return retryWithBackoff(); if (err.status === 401) return refreshCredentials(); if (err.status >= 500) return retryWithBackoff(); throw err; // 400/403/404/409 — fix the request } ``` ## Recognising specific errors The full list of specific error strings — the ones you'll see in real integrations — is on [Error codes](../reference/error-codes.md). They're grouped by HTTP status and cross-referenced against the routes that produce them.