Skip to Content
Integration GuidesErrors & Status Codes

Errors and status codes

Bella uses standard HTTP status codes. When an error occurs, the response includes a JSON error payload explaining the reason.

API Request503 Retryable4xx Client ErrorYour BackendBella APIExponential BackoffHandle Error

Error response envelope

Error responses return a JSON object with a detail key:

{ "detail": "No such thread." }

For schema validation errors (422), detail contains an array of validation issues:

{ "detail": [ { "type": "string_too_long", "loc": ["body", "text"], "msg": "String should have at most 4000 characters", "ctx": { "max_length": 4000 } } ] }

HTTP status codes

Status codeMeaningDescription
200 OKSuccessThe request succeeded.
201 CreatedCreatedA resource was created (member or thread).
204 No ContentNo contentSucceeded with no response body.
401 UnauthorizedAuth failedMissing, invalid, or revoked integration key.
404 Not FoundNot foundResource does not exist, or belongs to another organisation.
409 ConflictOnboarding pendingMember has onboarding phases with status: "pending". Complete onboarding before opening threads or sending messages.
422 Unprocessable EntityValidation errorRequest payload or query parameter failed schema validation.
503 Service UnavailableUnavailableCoach model temporarily busy. Safe to retry with backoff.

Organisation scoping and 404 responses

Requests are scoped to the organisation owning the integration key:

  • If a requested resource does not exist in your organisation, the endpoint returns 404 Not Found.
  • Resources belonging to other organisations also return 404 Not Found so IDs from other accounts cannot be probed.

Handling 503 errors and retries

HTTP status 503 Service Unavailable occurs when the upstream model is temporarily overloaded:

{ "detail": "The Coach is not available right now." }

Retry strategy

  1. Do not retry 4xx errors: 401, 404, 409, and 422 represent client errors that will not succeed without modifying the request or completing onboarding.
  2. Retry 503 with backoff and jitter: Retry up to 3 times with exponential backoff (e.g. 1s, 2s, 4s) plus randomised jitter to prevent thundering herds.
  3. UI fallback: If retries fail, inform the user and prompt them to try again shortly.

Production error handler implementations

Here are production-ready error handling and retry examples in cURL, TypeScript, and Python:

You can inspect response headers and status codes using curl -i:

curl -i -X POST "https://api.bellacoach.ai/api/v1/threads/thr_nonexistent/messages" \ -H "Authorization: Bearer $BELLA_API_KEY" \ -H "Content-Type: application/json" \ -d '{"text": "Hello"}'

Response:

HTTP/2 404 content-type: application/json {"detail":"No such thread."}

Next steps

Last updated on