API Reference

Errors

Error response format, status codes, rate limits, and retry guidance

Every API error response uses this envelope:

{
  "error": {
    "type": "validation_error",
    "code": "missing_document_url",
    "message": "document_url is required and must be a string",
    "request_id": "req_abc123def456"
  }
}

Error types

TypeStatusMeaning
authentication_error401Missing, invalid, expired, or revoked key
authorization_error403Key is valid but lacks the required scope
validation_error400Invalid body, path, query, or idempotency use
not_found404Resource does not exist for the organization
billing_error402Live billing or live usage gate blocked
precondition_error428Required legal or setup precondition missing
rate_limit_error429Per-key rate limit or monthly test-session cap exceeded
internal_error500Unexpected Klarefi server error

Error codes

CodeHTTP statusMeaningWhat to do
invalid_api_key401The API key is missing, invalid, revoked, expired, or for the wrong environmentReplace an expired/rotated key or send a valid key
forbidden403The key does not have the required scopeAdd the scope or use a key with the right access
billing_required402Live API access requires active billingEnable billing or use a test key
live_usage_cap_exceeded402The workspace reached its live usage capWait for the cap to reset or increase the cap
precondition_required428A required account precondition is missingComplete the setup step described in the message
legal_acceptance_required428Current self-serve legal terms must be acceptedAccept the current terms before live API access
self_serve_webhooks_disabled428Self-serve webhook delivery is disabled for this deploymentEnable self-serve webhooks before creating intake work
rate_limit_exceeded429The key exceeded its per-minute rate limitRetry after Retry-After or X-RateLimit-Reset
test_usage_cap_exceeded429The workspace created 50 test API sessions in the current UTC monthWait for the next month before creating another test session
invalid_request400The request is malformedFix the body, path, query, or headers
invalid_json400The JSON body could not be parsedSend valid JSON with Content-Type: application/json
invalid_connector_payload400Connector manifest validation failedFix the connector fields in the response message
missing_connector_key400A connector key was required but missingProvide connector_key or the path connector key
openapi_fetch_failed400The OpenAPI URL could not be fetchedConfirm the URL is public HTTPS and returns JSON
missing_openapi_spec400No OpenAPI source was providedSend openapi_url, openapi_json, or openapi
openapi_yaml_not_supported400YAML OpenAPI specs are not acceptedConvert the spec to JSON before import
invalid_openapi_spec400The OpenAPI document could not be parsedSend a valid OpenAPI JSON document
invalid_openapi_connector400A connector could not be generated from the specFix unsupported or incomplete connector metadata
missing_document_url400document_url is missing from POST /processSend a public HTTPS document URL
invalid_document_url400document_url is not an allowed public HTTPS URLUse a public HTTPS URL, not private or local network
per_request_webhook_url_not_supported400Per-request webhook URLs are not supportedRegister webhook endpoints in the dashboard
missing_case_type_id400case_type_id is requiredSend a configured case type ID
invalid_integration_identity400Integration identity fields are invalidSend non-empty string identity fields
missing_idempotency_key400An idempotency key is requiredSend idempotency_key or Idempotency-Key
idempotency_key_conflict400The idempotency key was reused with different parametersGenerate a new key for different work
external_case_id_conflict400The external case ID already exists for the organizationUse the existing case or a different external ID
missing_case_id400A case ID path segment is missingInclude the case ID in the URL
invalid_after_cursor400after_cursor is not an integerSend an integer cursor, usually the previous next_cursor
invalid_limit400limit is outside the allowed event page size rangeSend an integer from 1 to 500
missing_doc_id400A document ID path segment is missingInclude the document ID in the URL
invalid_acknowledgement_payload400Webhook acknowledgement payload validation failedSend a valid acknowledgement_id or omit it
webhook_delivery_not_delivered400The delivery cannot be acknowledged before a successful deliveryWait until the delivery status is delivered
missing_endpoint_url400endpoint_url is missing from webhook testSend a public HTTPS receiver URL
missing_signing_secret400signing_secret is missing from webhook testSend the endpoint signing secret
invalid_endpoint_url400endpoint_url is not an allowed public HTTPS URLUse a public HTTPS URL, not private or local network
not_found404The requested resource was not found for the organizationCheck the ID and environment
internal_error500Klarefi hit an unexpected server errorRetry if safe and contact support with request_id

Rate limits

Authenticated success responses include:

HeaderDescription
X-RateLimit-LimitMaximum requests per minute
X-RateLimit-RemainingRemaining requests in the window
X-RateLimit-ResetEpoch seconds when the window resets

When the limit is exceeded, Klarefi returns 429 rate_limit_error and may include Retry-After. The 429 response also includes the same X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers.

Retry guidance

Retry 429 responses after the rate-limit reset. Retry network failures with the same idempotency key. Do not blindly retry 400, 401, 403, 404, 402, or 428 responses; those require a request or account-state change.

The test-session monthly cap resets at the start of each UTC calendar month. Idempotent replays do not consume another session from the cap.

On this page