Backend

Errors

One error shape for every endpoint; branch on type and code, log the request id.

View as Markdown

Errors use HTTP status codes and a JSON body:

{
  "error": {
    "type": "invalid_request",
    "code": "unsupported_check",
    "message": "…",
    "param": "key",
    "request_id": "req_…"
  }
}
FieldUse
typeThe category — decides what to do (fix the request, re-authenticate, retry…).
codeThe specific reason. Stable; safe to branch on.
messageFor developers and logs; may change. Don't show it to applicants as-is.
paramThe request field at fault, when there is one.
request_idInclude it when you contact support.

Types

TypeHTTPWhat to do
invalid_request400Fix the request; retrying won't help.
authentication401Check the API key (or, in the flow, the client token).
permission403The key or user may not do this (role, mode, IP allowlist).
not_found404Wrong id, or it belongs to the other mode (test vs live).
conflict409The resource is in the wrong state (e.g. the session is closed).
idempotency409See idempotency.
rate_limit429Back off; honour Retry-After.
provider_unavailable503An upstream source is down. Retry later.
internal500Our fault. Retry with backoff; contact support with the request_id.

Every code the API can return is listed in the generated error code reference.

In @okyc/node

Errors are typed by type, and every error has type, code, param, requestId and statusCode:

ClassFor
InvalidRequestErrorinvalid_request
AuthenticationErrorauthentication
PermissionErrorpermission
NotFoundErrornot_found
ConflictErrorconflict and idempotency
RateLimitErrorrate_limit (with retryAfter in seconds)
ProviderUnavailableErrorprovider_unavailable
ConnectionErrornetwork failure or timeout (the request may or may not have reached the API)
ApiErrorbase class of all of them

They're exported from the package and available as Okyc.errors.*.

On this page