Errors and status codes
Bella uses standard HTTP status codes. When an error occurs, the response includes a JSON error payload explaining the reason.
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 code | Meaning | Description |
|---|---|---|
200 OK | Success | The request succeeded. |
201 Created | Created | A resource was created (member or thread). |
204 No Content | No content | Succeeded with no response body. |
401 Unauthorized | Auth failed | Missing, invalid, or revoked integration key. |
404 Not Found | Not found | Resource does not exist, or belongs to another organisation. |
409 Conflict | Onboarding pending | Member has onboarding phases with status: "pending". Complete onboarding before opening threads or sending messages. |
422 Unprocessable Entity | Validation error | Request payload or query parameter failed schema validation. |
503 Service Unavailable | Unavailable | Coach 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 Foundso 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
- Do not retry 4xx errors:
401,404,409, and422represent client errors that will not succeed without modifying the request or completing onboarding. - 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.
- 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:
cURL
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