Errors
Every failure returns a JSON body in one common format and a meaningful HTTP status code.
Branch on the status code and on error.code; use error.message for display and
logging.
The error envelope
Every endpoint — including POST /v1/auth/token — returns
the same shape for every 4xx and 5xx response:
{
"success": false,
"error": {
"status": 400,
"code": "VALIDATION_ERROR",
"message": "One or more fields are invalid. See 'details' for more information.",
"details": [{ "field": "teamIds", "message": "Team IDs must be valid GUIDs" }],
"traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
"timestamp": "2026-11-16T09:00:00Z"
}
}
| Field | Notes |
|---|---|
success | Always false for an error |
error.status | Same value as the HTTP status code |
error.code | Stable, machine-readable UPPER_SNAKE_CASE code. Branch on this |
error.message | Human-readable and safe to show. Do not parse — wording may change |
error.details | Field-level validation errors. Omitted when there are none |
error.traceId | Quote it when contacting support |
error.timestamp | When the error occurred (UTC, ISO 8601) |
Common error codes
| Code | Status | Meaning |
|---|---|---|
VALIDATION_ERROR | 400 | A field is missing or invalid — see details |
INVALID_JSON | 400 | The body is not valid JSON |
BUSINESS_RULE_VIOLATION | 400 | The request is valid but a business rule rejected it |
INVALID_CLIENT | 401 | Wrong client ID or secret |
TOKEN_MISSING | 401 | No bearer token was sent |
TOKEN_EXPIRED | 401 | The token has expired — get a new one |
TOKEN_INVALID | 401 | The token is malformed or its signature is invalid |
INSUFFICIENT_SCOPE | 403 | The token lacks the scope this endpoint requires |
SENDER_INVALID | 403 | X-Sender-Id is missing, unknown, inactive or not in your organization |
FORBIDDEN | 403 | The sender is not allowed to perform this operation on this resource |
NOT_FOUND | 404 | The resource does not exist or is not visible to your organization |
CONFLICT | 409 | The resource is not in a state that allows this operation |
UNSUPPORTED_MEDIA_TYPE | 415 | Wrong Content-Type |
CLIENT_LOCKED_OUT | 429 | Too many failed authentication attempts |
RATE_LIMITED | 429 | Too many requests |
INTERNAL_ERROR | 500 | Unexpected server error |
SERVICE_UNAVAILABLE | 503 | A dependency is unavailable |
Status codes
| Status | Meaning | Retry? |
|---|---|---|
200 | Success | — |
201 | Created | — |
400 | Malformed request, a missing required field, or a business rule | No — fix the request |
401 | Token missing, expired or invalid | Yes — get a new token, retry once |
403 | Missing scope, invalid sender, or the sender lacks permission | No — see Scopes |
404 | Resource not found, or not visible to your organization | No |
409 | The resource's current state does not allow the operation | No — check its state first |
429 | Locked out or rate limited | Yes — after waiting |
500 | Unexpected server error | Yes — with backoff |
503 | A dependency is unavailable | Yes — with backoff |
On 404
A file that exists but belongs to another organization — or that your sender is not
allowed to see — returns 404, not 403. The cases are deliberately indistinguishable so
the API cannot be used to discover whether an identifier exists elsewhere in the system.
On 401 versus 403
This is the distinction most worth getting right:
401— we do not know who you are. A new token usually fixes it.403— we know exactly who you are, and you are not allowed. Retrying never helps; the credential needs a scope added, or the sender needs the permission.
Handling errors well
Retry only what is retryable. 401 (once, after refreshing), 429 (after waiting),
500 and 503 (with exponential backoff). Never retry 400, 403, 404 or 409 — the
outcome will not change.
Cap your retries. One retry after a 401 is sufficient. More than that turns an
expired credential into a request storm and can trigger a lockout.
Log the traceId. It identifies the request in our logs and is the fastest way to
resolve a support case.
Do not branch on message. It is written for humans and may be reworded at any time.
Branch on the status code and error.code.
Example
async function callApi(url, token, senderId) {
const res = await fetch(url, {
headers: { Authorization: `Bearer ${token}`, 'X-Sender-Id': senderId },
});
if (res.ok) return res.json();
const { error } = await res.json();
switch (res.status) {
case 401:
throw new AuthError('Token rejected — refresh and retry once', error);
case 403:
// Not retryable: missing scope or the sender lacks the permission.
throw new ForbiddenError(error.code, error);
case 404:
return null;
case 429:
throw new RetryLaterError('Locked out or rate limited', error);
case 500:
case 503:
throw new TransientError(`Server error ${res.status}`, error);
default:
throw new ApiError(error.code, error);
}
}