Status codes
Every HTTP status ulex returns, what it means for each surface, which are retryable, the ulex error code that goes with each, and the status codes a well-behaved client should special-case.
#The table
| Status | type | Retryable | Means | Fix |
|---|---|---|---|---|
| 200 | — | — | success, or a deliberate non-2xx-success | — |
| 201 | — | — | created | — |
| 202 | — | — | accepted, no body: an MCP notification, a queued job | poll |
| 204 | — | — | deleted, no body | — |
| 206 | — | — | partial content, an NDJSON export stream | consume the stream |
| 302 | — | — | SAML login redirect; end_session redirect | follow it |
| 303 | — | — | form_post authorization success; the hosted UI | follow it |
| 304 | — | — | cached JWKS, metadata, or discovery document | use your cache |
| 307 | — | — | a permanent redirect, alias host | update the URL |
| 400 | invalid_request_error | no | the request is wrong | read param and details |
| 401 | authentication_error | no | missing, wrong, expired, or revoked credential | fix the credential |
| 403 | permission_error | no | authenticated, not permitted | broaden the scope or the policy |
| 404 | not_found_error | no | no such resource in this tenant | check the id prefix and the key's tenant |
| 405 | invalid_request_error | no | the method does not exist on that path | check the OpenAPI document |
| 409 | conflict_error | no | state conflict | read state before acting |
| 410 | not_found_error | no | soft-deleted and past the restore window | — |
| 412 | invalid_request_error | no | a precondition failed: domain_not_verified, a stale If-Match | satisfy the precondition |
| 413 | invalid_request_error | no | over a size limit: a Bulk request, an export window | chunk it |
| 415 | invalid_request_error | no | wrong Content-Type | use application/json, or application/scim+json on /scim/v2 |
| 422 | invalid_request_error | no | a semantically invalid but well-formed body | read details |
| 429 | rate_limited | no | per-IP request rate limit | honour Retry-After |
| 500 | api_error | yes | our fault | back off, then report the request_id |
| 501 | api_error | no | not implemented: implicit flow in prod, changePassword in SCIM | use the supported path |
| 503 | api_error | yes | deploying, draining, or unavailable | back off with jitter |
| 504 | api_error | yes | an upstream dependency exceeded the deadline | retry; narrow the request if it persists |
#Status by type
The mapping is structural, with a small set of documented overrides.
type | Base status |
|---|---|
invalid_request_error | 400 |
authentication_error | 401 |
permission_error | 403 |
not_found_error | 404 |
conflict_error | 409 |
rate_limit_error | 429 |
api_error | 500 |
Overrides:
code | Status | Normally |
|---|---|---|
service_unavailable | 503 | 500 |
timeout | 504 | 500 |
domain_not_verified | 412 | 400 |
scim_bulk_exceeded | 413 | 400 |
scim_user_not_found | 404 | 400 |
scim_group_not_found | 404 | 400 |
deployment_not_found | 404 | 400 |
invalid_state_transition | 409 | 400 |
webhook_url_blocked | 400 | 400 (a 403 would suggest a permission problem; it is not) |
saml_clock_skew | 400 | 400 |
mfa_required, step_up_required, login_required, interaction_required, consent_required, account_selection_required | 401 | 403 |
token_expired, api_key_expired | 401 | 400 |
The interactive-auth codes are 401 rather than 403 deliberately: the client is unauthenticated for this request, and a 403 would suggest a permission problem the client cannot fix by authenticating differently.
They were 400 in practice until consent was built. core/errors.ts assigned every one of them a 401 and this table published the same, but oauthStatus in services/api/src/http.ts had a default: 400 that swallowed the whole set — so a client branching on the status had a fourth answer that no document contained. A consent_required response now also has a meaning: it is the answer when the person holds a valid session but has not approved the scopes the application asked for.
#Per surface
#REST
Standard. 200 for reads and updates, 201 for creates, 204 for deletes that have no body.
#OAuth endpoints
/oauth2/token and /oauth2/revoke use the OAuth error body, not the ulex envelope:
{
"error": "invalid_grant",
"error_description": "The authorization code has already been used.",
"error_uri": "https://docs.ulexid.com/api-reference/errors#invalid_grant",
"type": "authentication_error",
"code": "invalid_grant",
"request_id": "req_01M3PSW9R0175NAW62NYR403R8",
"retryable": false
}/oauth2/introspect returns 200 with {"active": false} for an unknown, expired, or revoked token. Never 401. Introspection must not be an oracle for token validity.
/oauth2/authorize returns 302 or 303 on success, and a rendered HTML error page with a 400 when redirect_uri or state does not validate. It does not redirect an unvalidated URI.
#SAML
/connections/{id}/saml/login returns 302 to the upstream IdP. The ACS returns 200 with a JSON result on success, and a 400 with the ulex envelope for every SAML-specific failure. Assertion-replay and clock-skew are 400, not 409, because they are properties of the submitted document.
#SCIM
RFC 7644 §3.12 error body:
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:Error"],
"status": "409",
"scimType": "uniqueness",
"detail": "A User with userName pat@acme.example already exists.",
"request_id": "req_01M3PSW9R0175NAW62NYR403R8"
}status inside the body is a string, matching the HTTP status. POST /scim/v2/Bulk returns 200 even when individual operations failed; per-operation status is in Operations[].
#Webhooks
There is no status to interpret: a failed delivery never reaches you. It is a webhook_delivery record with status: failed or dead_lettered, and a response_status describing what your endpoint answered.
#MCP
Protocol failures use standard JSON-RPC, inside a 200 HTTP response:
| JSON-RPC code | Meaning |
|---|---|
-32700 | parse error. The body is not JSON |
-32600 | invalid request. Wrong jsonrpc version, or a malformed frame |
-32601 | method not found. Usually a typo in tools/call |
-32602 | invalid params. The arguments do not match the schema |
-32603 | internal error |
Tool failures are not protocol failures: they arrive as result.isError: true with the ulex envelope in content[0].text. A client that only checks the HTTP status will treat a tool failure as a success.
HTTP-level on /mcp: 400 for a bad frame, 401 with a WWW-Authenticate pointing at the protected-resource metadata, 404 for an unknown tool, 429 for over 600/minute, 202 for a notification.
#What a client should special-case
type Outcome =
| { kind: "ok"; status: number; body: unknown }
| { kind: "error"; status: number; envelope: UlexErrorEnvelope };
export function classify(status: number, body: unknown): Outcome {
if (status >= 200 && status < 300) return { kind: "ok", status, body };
// 3xx: the OAuth and SAML endpoints use them for control flow, not errors.
if (status >= 300 && status < 400) return { kind: "ok", status, body };
// OAuth endpoints answer with error/error_description, not error{...}.
if (body && typeof body === "object" && "error" in body) {
const b = body as Record<string, unknown>;
if (typeof b.error === "string") {
return {
kind: "error",
status,
envelope: { error: { type: (b.type as string) ?? "invalid_request_error",
code: (b.code as string) ?? b.error, message: (b.error_description as string) ?? b.error,
request_id: (b.request_id as string) ?? "unknown", retryable: b.retryable === true } },
};
}
return { kind: "error", status, envelope: body as UlexErrorEnvelope };
}
// SCIM: status is a string, scimType carries the cause.
if (body && typeof body === "object" && "scimType" in body) return { kind: "error", status, envelope: mapScim(body) };
return { kind: "error", status, envelope: { error: { type: "api_error", code: "unknown",
message: `unparseable error body at status ${status}`, request_id: "unknown", retryable: status >= 500 } };
}The four cases worth a branch:
| Case | Action |
|---|---|
429 | read Retry-After; never parse hint if the header is present |
5xx with retryable: true | back off with jitter, max 5 attempts, 30 s total |
409 resource_exists on a create | not a failure — the object exists, which is what you wanted |
4xx with retryable: false | stop. The request is wrong; retrying cannot help |
#Headers on every response
x-ulex-request-id: req_01M3PSW9R0175NAW62NYR403R8
x-ulex-correlation-id: onboard-acme-2026-09-29
x-ratelimit-limit: 1000
x-ratelimit-remaining: 847
x-ratelimit-reset: 1790693172x-ratelimit-remaining is worth reading before a burst. Discovering remaining: 3 at call 597 of 600 is a worse failure mode than one that read it at the start.