Resources

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

StatustypeRetryableMeansFix
200——success, or a deliberate non-2xx-success—
201——created—
202——accepted, no body: an MCP notification, a queued jobpoll
204——deleted, no body—
206——partial content, an NDJSON export streamconsume the stream
302——SAML login redirect; end_session redirectfollow it
303——form_post authorization success; the hosted UIfollow it
304——cached JWKS, metadata, or discovery documentuse your cache
307——a permanent redirect, alias hostupdate the URL
400invalid_request_errornothe request is wrongread param and details
401authentication_errornomissing, wrong, expired, or revoked credentialfix the credential
403permission_errornoauthenticated, not permittedbroaden the scope or the policy
404not_found_errornono such resource in this tenantcheck the id prefix and the key's tenant
405invalid_request_errornothe method does not exist on that pathcheck the OpenAPI document
409conflict_errornostate conflictread state before acting
410not_found_errornosoft-deleted and past the restore window—
412invalid_request_errornoa precondition failed: domain_not_verified, a stale If-Matchsatisfy the precondition
413invalid_request_errornoover a size limit: a Bulk request, an export windowchunk it
415invalid_request_errornowrong Content-Typeuse application/json, or application/scim+json on /scim/v2
422invalid_request_errornoa semantically invalid but well-formed bodyread details
429rate_limitednoper-IP request rate limithonour Retry-After
500api_erroryesour faultback off, then report the request_id
501api_errornonot implemented: implicit flow in prod, changePassword in SCIMuse the supported path
503api_erroryesdeploying, draining, or unavailableback off with jitter
504api_erroryesan upstream dependency exceeded the deadlineretry; narrow the request if it persists

#Status by type

The mapping is structural, with a small set of documented overrides.

typeBase status
invalid_request_error400
authentication_error401
permission_error403
not_found_error404
conflict_error409
rate_limit_error429
api_error500

Overrides:

codeStatusNormally
service_unavailable503500
timeout504500
domain_not_verified412400
scim_bulk_exceeded413400
scim_user_not_found404400
scim_group_not_found404400
deployment_not_found404400
invalid_state_transition409400
webhook_url_blocked400400 (a 403 would suggest a permission problem; it is not)
saml_clock_skew400400
mfa_required, step_up_required, login_required, interaction_required, consent_required, account_selection_required401403
token_expired, api_key_expired401400

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:

json
{
  "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:

json
{
  "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 codeMeaning
-32700parse error. The body is not JSON
-32600invalid request. Wrong jsonrpc version, or a malformed frame
-32601method not found. Usually a typo in tools/call
-32602invalid params. The arguments do not match the schema
-32603internal 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

ts
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:

CaseAction
429read Retry-After; never parse hint if the header is present
5xx with retryable: trueback off with jitter, max 5 attempts, 30 s total
409 resource_exists on a createnot a failure — the object exists, which is what you wanted
4xx with retryable: falsestop. The request is wrong; retrying cannot help

#Headers on every response

http
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: 1790693172

x-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.

#Reference