Build

Error Handling

Understand error responses, HTTP status codes, and how to handle errors in the Lev API.

Updated March 2026

Error Format

All error responses include a request_id for correlation with support and a structured error object:

{
  "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "error": {
    "status": 404,
    "type": "not_found",
    "message": "Deal with id 999 not found",
    "details": {}
  }
}
FieldTypeDescription
statusintegerHTTP status code mirrored in the envelope for convenience
typestringShort machine-readable error type (see Status Codes below)
messagestringHuman-readable description
detailsobjectAdditional context; always present but may be empty
prerequisitesarray(optional) Actions required before the request can succeed
upgrade_urlstring(optional) URL to upgrade the account when the error is tier-gated

The request_id matches the value logged in usage tracking, so it can be referenced when contacting support.

Status Codes

CodetypeMeaning
200OK — successful read or update
201Created — successful resource creation
400bad_requestInvalid request body, missing required fields, malformed query parameters
401unauthorizedMissing, invalid, or expired authentication token
403forbiddenValid token but insufficient permissions
404not_foundResource doesn't exist or isn't accessible to the authenticated user
409conflictIdempotency conflict (different request body with same idempotency key)
422validation_errorValid JSON but semantically invalid (e.g., invalid enum value)
429rate_limit_exceededRate limit exceeded
500internal_errorUnexpected server error

Common Errors

Missing authentication

{
  "request_id": "...",
  "error": {
    "status": 401,
    "type": "unauthorized",
    "message": "Authentication required",
    "details": {}
  }
}

Resource not found

Returns 404 both when a resource doesn't exist and when the authenticated user doesn't have access to it. This prevents information leakage about resource existence.

{
  "request_id": "...",
  "error": {
    "status": 404,
    "type": "not_found",
    "message": "Deal with id 999 not found",
    "details": {}
  }
}

Validation error

{
  "request_id": "...",
  "error": {
    "status": 422,
    "type": "validation_error",
    "message": "Invalid value for field 'loan_type': must be one of [construction, heavy_bridge, light_bridge, permanent, land, predevelopment, tbd]",
    "details": {}
  }
}

Rate limited

{
  "request_id": "...",
  "error": {
    "status": 429,
    "type": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Retry after 30 seconds.",
    "details": {}
  }
}
More in this section