# Error codes Every error response uses the shape: ```json { "message": "..." } ``` The messages below are the ones your integration will encounter in practice. Group them by HTTP status when writing client-side handlers — the `message` wording may change without notice, but the status code + endpoint is stable. For the shape and general rules, see [Error model](../guides/error-model.md). ## 400 Bad Request | Message | When | Fix | |---------|------|-----| | `Idempotency-Key must be a valid UUID` | The `Idempotency-Key` header on a write request is not a UUID | Generate a UUID (any version — v4 is standard) | | `Unsupported grant type` | OAuth `POST /api/auth/oauth/token` with a `grant_type` other than `client_credentials` | Send `grant_type: "client_credentials"` | | *(validation-specific message)* | A field on the request body failed schema validation | Read the message, correct the field | | `Invalid token request` | OAuth `POST /api/auth/oauth/token` body is malformed, or a field is not a string | Send a well-formed form-encoded or JSON body | | `Webhook URL must resolve to a publicly reachable HTTPS endpoint` | The webhook URL points at a private, loopback or link-local address, or the hostname does not resolve | Register a publicly reachable HTTPS endpoint and forward inward from there | | `Insufficient scope for this operation` (with `"error": "invalid_scope"`) | The OAuth `scope` parameter asked for a scope the app does not hold | Request a subset of the app's scopes, or extend the app in the portal | ## 401 Unauthorized | Message | When | Fix | |---------|------|-----| | `API key is required` | The `x-api-key` header (or `Authorization: Bearer` for OAuth) is missing | Include the credential header | | `Invalid API key` | The key does not match any active developer app | Regenerate in the portal | | `API key has expired` | The key expired (keys issued from the portal last 90 days) | Rotate — see [Key rotation](../guides/key-rotation.md) | | `API key has been revoked` | The key was revoked in the portal | Generate a new key | | `Invalid client credentials` | OAuth `client_id` / `client_secret` do not match | Re-copy from the portal's Credentials page | | `Bearer token is required` | An OAuth-authenticated route was called without an `Authorization: Bearer …` header | Fetch a token via `/api/auth/oauth/token` | | `Invalid or expired bearer token` | The JWT is malformed, unsigned, or past its 15-minute TTL | Request a fresh token | ## 403 Forbidden | Message | When | Fix | |---------|------|-----| | `Application is not active` | The developer app was suspended or deleted in the portal | Ask the portal admin to reactivate | | `Request origin is not permitted` | The request's source IP is not in the key's / app's CIDR allowlist | Update the allowlist in the portal, or route through a permitted IP | | `Insufficient scope for this operation` | The key is valid but the app lacks a scope the route requires | Extend the app's scopes in the portal (does not invalidate keys) | | `Browser requests are not permitted on this API` | A browser sent an `Origin` header (`/api/v1/*` is not a browser-callable API) | Call from a server, not the browser | | `Request signature validation failed` | The optional request-signing header (`X-Gallantree-Request-Signature`) is present but wrong | Recompute the signature per the docs or drop the header | | `OAuth is not configured for this application` | The app has no OAuth client credentials issued | Enable OAuth for the app in the portal | ## 404 Not Found | Message | When | Fix | |---------|------|-----| | `Application not found` | Portal admin API — the app id does not resolve | Check the app id | | `Webhook subscription not found` | The webhook id does not resolve — either it never existed, was deleted, or belongs to another app | Verify the subscription id and its owning app | The `404` responses on resource routes (`/api/v1/loans/{id}`, etc.) return a generic message and never distinguish "doesn't exist" from "you can't see it" — that's a privacy measure, not a bug. ## 409 Conflict | Message | When | Fix | |---------|------|-----| | `A different request with this idempotency key already exists` | Same `Idempotency-Key` re-used with a different body within the 24h retention window | Use a fresh key, or send the same body | | `Duplicate external id.` | `POST /loans` or `POST /organisations` sent an `externalId` that is already registered by a different integration source | Use the `externalId` your integration registered, or a new one | | `Source system mismatch.` | `POST /loans` or `POST /organisations` tried to update a record that was created under a different integration source | Update the record from the source that created it | | `This loan already exists. Changing an existing loan isn't supported yet.` | `POST /loans` re-sent an existing loan's `externalId` with an organisation or collateral the loan wasn't created with; `errors` names each one | Send the loan as it was created, or wait for the loan update path | | `Maximum webhook subscriptions reached for this application` | `POST /webhooks` when the app already has 10 active subscriptions | Delete a subscription you no longer need | ## 429 Too Many Requests | Message | When | Fix | |---------|------|-----| | `Too many failed authentication attempts. Please try again later.` | Too many rejected credentials from your IP in a short window | Stop retrying, fix the credential, then resume — honour `Retry-After`. Only *rejected* credentials count; valid traffic never fills this budget | | `Too many requests. Please try again later.` | Tier rate limit, or the OAuth token endpoint's per-IP limit | Honour `Retry-After`; see [Rate limits](../guides/rate-limits.md), and cache OAuth tokens until they expire rather than fetching one per call | ## 500 Internal Server Error Deliberately generic. If you see one, capture: - The timestamp of the request. - The route + method. - Your app id. Contact support with those three fields — the server-side log has the detail that the response deliberately omits. Responses do not yet carry a request id. ## 502 Bad Gateway | Message | When | Fix | |---------|------|-----| | `Webhook test delivery failed` | `POST /webhooks/{webhookId}/test` could not deliver to your endpoint. The body also carries `httpStatus` and `responseTimeMs` | Check the endpoint is publicly reachable and returns `2xx`, then test again | ## 503 Service Unavailable | Message | When | Fix | |---------|------|-----| | `Service temporarily unavailable` | Maintenance window or upstream dependency outage | Retry with back-off; honour `Retry-After` | | `Failed to create application` / `Failed to update application` | Rare admin-API failures on portal writes | Retry; if persistent, contact support |