API

Errors

The single ulex error envelope: type, code, message, param, request_id, retryable, docs_url, hint, details. Every error code with its HTTP status, whether it is retryable, its causes, and its fix.

Every surface — REST, MCP, CLI, and webhook delivery failures — returns the same object. You learn one grammar.

json
{
  "error": {
    "type": "conflict_error",
    "code": "resource_exists",
    "message": "A organization with that slug already exists.",
    "param": "slug",
    "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
    "retryable": false,
    "docs_url": "https://docs.ulexid.com/api-reference/errors",
    "hint": "Reuse the existing organization id, or choose a different slug.",
    "details": { "slug": "already taken" }
  }
}

#Fields

FieldTypeAlways presentUse it for
typeenumyeschoosing the HTTP status family, and coarse branching
codeenumyesthe exact failure. Branch on this, not on message
messagestringyeshumans. Never parse it
paramstringnothe offending request field. Map it back to your form/input
request_idstringyesquote it in a bug report; it is in the audit log
retryablebooleanyesthe only thing you need for backoff
docs_urlstringnoa deep link to the relevant page
hintstringnothe next action. On 429s this is "Retry after 17s."
detailsRecord<string, string | string[]>noper-field validation messages

#Type to status

typeStatusRetryable?Meaning
invalid_request_error400nothe request is wrong
authentication_error401nocredential missing, wrong, expired, revoked
permission_error403noauthenticated, not allowed
not_found_error404nono such resource in this tenant
conflict_error409nostate conflict
rate_limited429norequest shield blocked this source IP; honor Retry-After
api_error500yesour fault

Status overrides: service_unavailable → 503, timeout → 504, domain_not_verified → 412, scim_bulk_exceeded → 413, scim_user_not_found → 404, scim_group_not_found → 404, deployment_not_found → 404, invalid_state_transition → 409, webhook_url_blocked → 400, saml_clock_skew → 400, and all the OAuth interaction codes (mfa_required, step_up_required, login_required, interaction_required, consent_required, account_selection_required, token_expired, api_key_expired) → 401.

#retryable

A closed set. Nothing else is ever retryable.

coderetryableWhy
internal_errortruetransient server fault
service_unavailabletruedeploying, draining, or degraded
timeouttrueupstream did not answer in time
webhook_delivery_failedtruedelivery-side, not caller-side
deployment_failedtruethe deployment subsystem retried internally
scim_bulk_failedtruepartial bulk; the remaining operations were skipped
everything elsefalseretrying cannot help

#Backoff

text
attempt = 0
loop:
  result = call(request)
  if not an error envelope: return result
  if result.error.retryable is false: return result
  attempt += 1
  if attempt > 5: return result
  if result.status == 429:
      wait = seconds from the `Retry-After` response header
  elif attempt <= 2: wait = 0.5 * attempt
  else:            wait = 2 ** (attempt - 2)
  sleep(wait)

Cap total retry time at 30 seconds. Add jitter of up to 20% so a fleet of agents does not resynchronise.

#Error codes

#Generic

codeStatustypeRetryableCause → fix
invalid_request400invalid_request_errornomalformed body or query → fix the field named in param
invalid_json400invalid_request_errornobody is not parseable JSON → check for a trailing comma, a smart quote, a ${} that was never substituted
missing_parameter400invalid_request_errornoa required field is absent → param names it
unknown_parameter400invalid_request_errornoa field you sent is not in the schema → most often environment. Objects are strict; extra keys are rejected on purpose so typos surface
validation_failed400invalid_request_errornoa field failed its schema → details maps field path to message
internal_error500api_erroryesour bug → retry up to 5 times, then GET /status and report the request_id
service_unavailable503api_erroryesdeploying or draining → retry with backoff
timeout504api_erroryesupstream exceeded the deadline → retry; if it persists, lower limit or narrow the filter

#Authentication and authorization

codeStatustypeCause → fix
unauthenticated401authentication_errorno Authorization header → add one
invalid_api_key401authentication_errormalformed key, wrong length, or stray whitespace → copy the full value
api_key_expired401authentication_errorpast expires_at → mint a new one
api_key_revoked401authentication_errorrevoked → mint a new one; do not retry
invalid_token401authentication_errornot a JWT, wrong issuer, or bad signature → check iss equals https://ulexid.com (or your local issuer)
token_expired401authentication_errorexp in the past → refresh, or re-login if no refresh token
token_revoked401authentication_errorrevoked explicitly, or refresh-token family reuse → restart the flow
insufficient_scope403permission_errorscope missing → read hint for the exact scope
cross_tenant403permission_errorthe resource belongs to another tenant → you cannot see it; treat as 404 in your UI
invalid_client401authentication_errorunknown client_id
invalid_grant400authentication_errorthe authorization code is expired, already consumed, or the redirect_uri does not match → re-login, do not retry
unauthorized_client403permission_errorthe grant type is not enabled on the application
unsupported_grant_type400invalid_request_erroradd the grant to the application's grant_types
invalid_redirect_uri400invalid_request_errornot in the application's redirect_uris → copy the exact string; a trailing slash is a different URI
invalid_request_uri400invalid_request_errorrequest_uri JARM is not enabled
invalid_pkce_verifier400invalid_request_errordoes not match the stored challenge
code_verifier_mismatch400invalid_request_errorPKCE S256 mismatch → recompute code_challenge = base64url(sha256(code_verifier))
invalid_state400invalid_request_errorstate did not round-trip → your session lost it
invalid_nonce400invalid_request_errornonce did not round-trip
session_expired401authentication_erroridle or absolute timeout
password_policy_not_met400invalid_request_errordoes not meet the tenant's authPolicy.password → read error.message, which names every unmet rule at once
access_denied403permission_errorsuspended user, source in blocked_ip_ranges, direct sign-in attempted when organization.sso_only is true, or joining with an unverified domain when allow_profiles_outside_organization is false
login_required401authentication_errorprompt=none and no session → re-run without prompt=none
interaction_required401authentication_errorprompt=none and interaction is required
consent_required401authentication_errorthe person holds a session but has not approved the scopes this application asked for. prompt=none forbids showing the approval screen
account_selection_required401authentication_errormultiple accounts, no session
mfa_required401authentication_errorMFA challenge outstanding → call ulex_simulate_mfa with mode: "satisfy", or present the challenge to a human
step_up_required401authentication_erroracr_values demanded more than the session has

#Resources

codeStatustypeCause → fix
not_found404not_found_errorno such id in this tenant → check the prefix (org_, usr_, con_, …)
resource_exists409conflict_errorslug, email, or name collision → reuse the id, or pass an Idempotency-Key
resource_deleted409conflict_errorsoft-deleted; within the 30-day restore window it is still in the audit log but not readable
immutable_field409conflict_erroryou tried to change id, slug, object, or created_at
limit_reached400invalid_request_errorarray at capacity — 50 redirect URIs, 500 domains, 20 ACS URLs, 200 blocked IP ranges

#SSO, SAML, SCIM

codeStatustypeCause → fix
saml_request_invalid400invalid_request_errorthe AuthnRequest is not well-formed XML, or the SAMLRequest is not correctly deflated and base64-encoded
saml_response_invalid400invalid_request_errorthe Response is malformed, or Destination does not equal the ACS URL
saml_signature_invalid400invalid_request_errorthe signature does not verify against the connection's certificate → POST /connections/{id}/verify, then re-upload the cert
saml_nameid_mismatch400invalid_request_errorthe NameID does not resolve to a user and allow_link is false
saml_acs_mismatch400invalid_request_errorInResponseTo does not match an outstanding request, or the ACS URL is not in acs_allowed_urls
saml_replay_detected400invalid_request_errorthis assertion ID has already been consumed → a replay, or the IdP retried. Both are legitimate; ulex rejects the second
saml_clock_skew400invalid_request_errorNotOnOrAfter is outside allowed_clock_skew_seconds (default 120) → sync clocks or raise the tolerance to at most 600
scim_invalid_filter400invalid_request_errorthe filter parameter is not valid SCIM filtering syntax
scim_invalid_syntax400invalid_request_errorthe body is not valid SCIM JSON
scim_conflict409conflict_erroruserName or externalId already exists in this directory
scim_user_not_found404not_found_errorno user with that id
scim_group_not_found404not_found_errorno group with that id
scim_bulk_failed500api_errora Bulk operation failed → read Operations[].response.status
scim_bulk_exceeded413invalid_request_errormore than 100 operations in one Bulk request
directory_not_synced409conflict_erroryou read sync state before the first run completed → trigger a sync first

#Domains

codeStatustypeCause → fix
domain_not_verified412invalid_request_errorPOST /organizations/{id}/domains/{domainId}/verify, or publish the TXT record when allow_mocks is false
sso_domain_required409conflict_errorremoving the last verified domain of an sso_only org → verify a replacement first, or set sso_only to false
domain_already_verified409conflict_erroralready verified → this is a no-op, not a failure
domain_verification_failed500api_errorthe lookup itself failed → retry

#Webhooks

codeStatustypeCause → fix
webhook_url_invalid400invalid_request_errornot an https:// URL, or contains credentials
webhook_url_blocked400invalid_request_errorSSRF guard: loopback, link-local, RFC 1918, or a blocked metadata endpoint
webhook_delivery_failed500api_errordelivery-side. Your endpoint is not answering 2xx within 5 seconds
webhook_signature_invalid400invalid_request_erroryour receiver rejected a signature → check the Ulex-Signature construction and the secret

#Deployments and jobs

codeStatustypeCause → fix
deployment_failed500api_errorread deployment.error.code; retryable says whether a re-run can work
deployment_not_found404not_found_errorno deployment with that id
invalid_state_transition409conflict_errore.g. cancelling a succeeded deployment → read state first
job_cancelled409conflict_errora running job was cancelled

#MCP

codeStatustypeCause → fix
mcp_unauthorized401authentication_errorno Authorization header, or the key lacks mcp:tools
mcp_tool_not_found404not_found_errorwrong tool name → call ulex_list_tools and match exactly

#JSON-RPC error mapping over MCP

MCP wraps tool errors in a successful JSON-RPC response, because a tool failure is not a protocol failure:

json
{
  "jsonrpc": "2.0",
  "id": 7,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"error\":{\"type\":\"permission_error\",\"code\":\"insufficient_scope\",\"message\":\"This credential requires the write:organizations scope.\",\"request_id\":\"req_01M3PSW9R0175NAW62NYR403R8\",\"retryable\":false,\"hint\":\"Request scope: write:organizations.\"}}"
      }
    ],
    "isError": true
  }
}

Protocol-level problems — malformed JSON-RPC, unknown method, bad jsonrpc version — use the standard JSON-RPC error object instead:

json
{
  "jsonrpc": "2.0",
  "id": 7,
  "error": { "code": -32601, "message": "Method not found", "data": { "method": "tools/calll" } }
}

isError: true means read the ulex envelope out of content[0].text. JSON-RPC error codes: -32700 parse error, -32600 invalid request, -32601 method not found, -32602 invalid params, -32603 internal error.

#SCIM error body

SCIM endpoints return a different envelope, because RFC 7644 §3.12 mandates it:

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"
}
scimTypeHTTPMeaning
invalidFilter400bad filter syntax
tooMany400filter returned more than one match; add an equality condition
uniqueness409userName or externalId collision
mutability400you tried to change an immutable attribute (id, schemas)
invalidSyntax400body is not valid SCIM JSON
invalidPath400path in a PATCH does not exist
noTarget400PATCH operation targeted a missing attribute

Map scimType back to the ulex envelope if your agent only speaks one error grammar:

ts
const TYPE_BY_SCIM: Record<string, UlexErrorType> = {
  invalidFilter: "invalid_request_error",
  tooMany: "invalid_request_error",
  invalidSyntax: "invalid_request_error",
  invalidPath: "invalid_request_error",
  mutability: "conflict_error",
  uniqueness: "conflict_error",
};

#Webhook delivery failures

Failures do not reach you as a response. They are recorded as a webhook_delivery and visible at GET /webhooks/{id}/deliveries:

json
{
  "id": "dlv_01M3PSVM8G1BF1SQ3FQ0FPKJJA",
  "object": "webhook_delivery",
  "webhook_id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
  "event": "user.created",
  "event_id": "evt_01M3PSW3WGDDFJFJHZ4QJNNFZD",
  "status": "delivered",
  "attempt": 1,
  "max_attempts": 8,
  "response_status": 200,
  "response_body": "{\"received\":true}",
  "error": null,
  "duration_ms": 84,
  "next_attempt_at": null,
  "delivered_at": "2026-09-29T14:42:18.000Z"
}

#Decoding a code

If you have a code and no context:

json
{ "name": "ulex_explain_error", "arguments": { "code": "saml_signature_invalid" } }
json
{
  "code": "saml_signature_invalid",
  "type": "invalid_request_error",
  "http_status": 400,
  "retryable": false,
  "message": "The SAML assertion signature did not verify against the connection's configured certificate.",
  "causes": [
    "The IdP is signing with a different certificate than the one on the connection.",
    "The certificate was rotated upstream and ulex still has the old one.",
    "The assertion is signed with a weak algorithm the connection does not allow."
  ],
  "fixes": [
    "Download the current signing certificate from the IdP and PATCH /connections/{id} with config.saml.x509_certificate.",
    "Call POST /connections/{id}/verify to re-validate before retrying the login.",
    "Confirm config.saml.signature_validation is 'strict' and signature_algorithm matches the IdP."
  ],
  "docs_url": "https://docs.ulexid.com/troubleshooting/saml-issues"
}

Deeper: Common errors, Status codes.