Error Codes
Complete reference for Chatsby API error responses — HTTP status codes, error types, common causes, and how to fix them.
The Chatsby API uses conventional HTTP status codes to indicate whether a request succeeded or failed. Every error response follows a consistent JSON format so your application can handle failures programmatically.
Error Response Format
All error responses return a JSON body with a top-level error object:
{
"error": {
"type": "invalid_request_error",
"message": "The 'agent_id' field is required.",
"code": "missing_required_field",
"param": "agent_id",
"status": 400
}
}Error Object Fields
| Field | Type | Always Present | Description |
|---|---|---|---|
type | string | Yes | Error category. Used for programmatic handling. |
message | string | Yes | Human-readable explanation. Do not parse this programmatically — the wording may change. |
code | string | Yes | Machine-readable error code. Stable across API versions. |
param | string | No | The request parameter that caused the error (for validation errors). |
status | integer | Yes | HTTP status code. |
Error Types
| Type | Description |
|---|---|
invalid_request_error | The request is malformed — missing fields, invalid parameters, or bad JSON. |
authentication_error | API key is missing, invalid, or expired. |
forbidden_error | The API key is valid but lacks permission for the requested action. |
not_found_error | The requested resource does not exist. |
conflict_error | The request conflicts with the current state of a resource. |
rate_limit_error | Too many requests. Slow down and retry. |
validation_error | The request body failed validation rules. |
server_error | Something went wrong on our end. |
HTTP Status Code Reference
400 Bad Request
The request is malformed or missing required information.
Common causes:
- Missing a required field (e.g.,
agent_id,message,name) - Invalid JSON in the request body
- Parameter value out of allowed range (e.g.,
temperature> 2.0) - Malformed URL in a website source
How to fix: Check the param field in the error response to identify which field caused the issue. Review the endpoint's parameter documentation.
{
"error": {
"type": "invalid_request_error",
"message": "The 'name' field is required when creating an agent.",
"code": "missing_required_field",
"param": "name",
"status": 400
}
}401 Unauthorized
The request lacks valid authentication credentials.
Common causes:
- No
Authorizationheader provided - Missing the
Bearerprefix in the header - API key is invalid, revoked, or expired
- Using a test key against production endpoints (or vice versa)
How to fix: Ensure your request includes Authorization: Bearer YOUR_API_KEY with a valid key from your dashboard.
{
"error": {
"type": "authentication_error",
"message": "Invalid API key provided. Check that your key is correct and has not been revoked.",
"code": "invalid_api_key",
"status": 401
}
}403 Forbidden
The API key is valid but does not have permission for the requested action.
Common causes:
- The API key's scoped permissions do not include the required scope (e.g., trying to create an agent with a key that only has
agents:read) - Attempting to access a resource that belongs to a different account
How to fix: Check the key's permissions in the dashboard. If the key needs additional scopes, create a new key or update the existing one.
{
"error": {
"type": "forbidden_error",
"message": "This API key does not have the 'agents:write' permission required for this action.",
"code": "insufficient_permissions",
"status": 403
}
}404 Not Found
The requested resource does not exist.
Common causes:
- The resource ID is incorrect or has a typo
- The resource has been deleted
- The resource belongs to a different account
How to fix: Verify the resource ID. Use the relevant list endpoint to confirm the resource exists.
{
"error": {
"type": "not_found_error",
"message": "No agent found with ID 'agent_nonexistent'.",
"code": "resource_not_found",
"param": "agent_id",
"status": 404
}
}409 Conflict
The request conflicts with the current state of a resource.
Common causes:
- Attempting to refresh a source that is already being processed
- Sending a message to a conversation that references a different agent than the one specified
- Creating a resource with a duplicate idempotency key but different parameters
How to fix: Check the current state of the resource and retry when the conflict condition has been resolved.
{
"error": {
"type": "conflict_error",
"message": "Source 'src_abc123defg' is currently being processed. Wait for processing to complete before requesting a refresh.",
"code": "resource_busy",
"status": 409
}
}422 Unprocessable Entity
The request body is well-formed JSON but fails validation rules.
Common causes:
- String field exceeds maximum length (e.g.,
system_prompt> 4,000 characters) - Metadata object has more than 20 keys
- Q&A source content is not valid JSON
- File upload exceeds the 10 MB limit
- Value is the wrong type (e.g., string where a number is expected)
How to fix: Review the validation constraints for the endpoint. The param field identifies the offending field, and the message explains the specific rule that was violated.
{
"error": {
"type": "validation_error",
"message": "The 'system_prompt' field must not exceed 4,000 characters. Received 4,523 characters.",
"code": "field_too_long",
"param": "system_prompt",
"status": 422
}
}Field-Level Validation Errors
When multiple fields fail validation, the response may include an errors array with details for each field:
{
"error": {
"type": "validation_error",
"message": "Multiple validation errors occurred.",
"code": "validation_failed",
"status": 422,
"errors": [
{
"param": "temperature",
"message": "Must be between 0.0 and 2.0. Received 3.5.",
"code": "out_of_range"
},
{
"param": "max_tokens",
"message": "Must be a positive integer. Received -100.",
"code": "invalid_value"
}
]
}
}429 Too Many Requests
You have exceeded the API rate limit for your key or plan.
Common causes:
- Sending more than the allowed number of requests per minute
- Burst of requests from a loop without throttling
- Multiple services sharing the same API key without coordination
How to fix: Implement exponential backoff. Check the Retry-After header for the number of seconds to wait before retrying.
{
"error": {
"type": "rate_limit_error",
"message": "Rate limit exceeded. Please retry after 12 seconds.",
"code": "rate_limit_exceeded",
"status": 429
}
}Rate limit headers included in the response:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests allowed per minute. |
X-RateLimit-Remaining | 0 (you have exhausted the window). |
X-RateLimit-Reset | Unix timestamp when the window resets. |
Retry-After | Seconds to wait before retrying. |
Recommended retry strategy with exponential backoff:
async function fetchWithRetry(url, options, maxRetries = 5) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
const response = await fetch(url, options);
if (response.status !== 429) {
return response;
}
const retryAfter = response.headers.get('Retry-After');
const delay = retryAfter
? parseInt(retryAfter, 10) * 1000
: Math.min(1000 * Math.pow(2, attempt), 30000); // Exponential backoff, max 30s
console.warn(`Rate limited. Retrying in ${delay / 1000}s...`);
await new Promise(resolve => setTimeout(resolve, delay));
}
throw new Error('Max retries exceeded');
}500 Internal Server Error
An unexpected error occurred on the Chatsby server.
Common causes:
- Temporary infrastructure issue
- Bug in the Chatsby backend
How to fix: Retry the request after a short delay. If the error persists, contact support with the request_id from the response headers.
{
"error": {
"type": "server_error",
"message": "An internal error occurred. Please try again later. If the problem persists, contact support with request ID: req_abc123.",
"code": "internal_error",
"status": 500
}
}503 Service Unavailable
The Chatsby API is temporarily unavailable, usually due to planned maintenance or high load.
Common causes:
- Scheduled maintenance window
- Temporary capacity constraints
How to fix: Wait and retry. Check status.chatsby.co for platform status and maintenance schedules.
{
"error": {
"type": "server_error",
"message": "The service is temporarily unavailable. Please try again in a few minutes.",
"code": "service_unavailable",
"status": 503
}
}Error Codes Summary Table
| Status | Code | Type | Description |
|---|---|---|---|
| 400 | missing_required_field | invalid_request_error | A required field is missing. |
| 400 | invalid_parameter | invalid_request_error | A parameter value is invalid. |
| 400 | invalid_json | invalid_request_error | The request body is not valid JSON. |
| 401 | invalid_api_key | authentication_error | The API key is invalid or missing. |
| 403 | insufficient_permissions | forbidden_error | The key lacks the required scope. |
| 404 | resource_not_found | not_found_error | The resource does not exist. |
| 409 | resource_busy | conflict_error | The resource is in a conflicting state. |
| 409 | idempotency_conflict | conflict_error | Same idempotency key with different params. |
| 422 | field_too_long | validation_error | A string field exceeds its max length. |
| 422 | out_of_range | validation_error | A numeric field is outside valid bounds. |
| 422 | invalid_value | validation_error | A field has the wrong type or format. |
| 422 | validation_failed | validation_error | Multiple validation errors. |
| 429 | rate_limit_exceeded | rate_limit_error | Too many requests. |
| 500 | internal_error | server_error | Unexpected server error. |
| 503 | service_unavailable | server_error | Temporary downtime. |
Every API response includes a X-Request-Id header with a unique identifier for the request. When contacting support about an error, include this ID so our team can trace the issue in our logs.
On this page