Skip to main content
Chatling uses conventional HTTP status codes to indicate whether a request succeeded. Failed requests return a 4xx or 5xx status and a JSON body with an error object. Handle errors by code, which doesn’t change, not by message, whose wording can.

Error format

Validation errors

If parameters are invalid, the API returns 422 validation_failed and lists every invalid parameter in errors, each with its own param and message. The top-level param and message match the first entry.

Error types

Error codes

Every code the API returns, grouped by type. New codes may be added, so handle unknown codes by their type.

authentication_error

No valid API key was provided.

permission_error

The API key or the project’s plan doesn’t allow the request.

not_found_error

The resource doesn’t exist, or the API key can’t access it.

invalid_request_error

The request has invalid parameters or conflicts with the resource’s current state. Fix the request before retrying, except for resource_busy and source_not_ready, which you can retry unchanged later.

idempotency_error

The Idempotency-Key can’t be used for this request.

rate_limit_error

Too many requests hit the API too quickly. Retry after Retry-After seconds.

api_error

Something went wrong on Chatling’s end. Retry shortly.

Handling errors

  • Retry rate_limit_error after the number of seconds in Retry-After, and api_error after a short wait.
  • Send POST requests with an Idempotency-Key, so a retry doesn’t run the request twice.
  • Retry resource_busy and source_not_ready later, unchanged. Don’t retry other errors without changing the request.