BookbagBookbag

Errors

The Bookbag error envelope and the common machine-readable codes. How v2 and the Chatbase-compatible v1 surfaces report failures, plus rate limiting.

View as Markdown

Bookbag uses conventional HTTP status codes and a consistent JSON envelope so you can branch on a stable, machine-readable code rather than parsing prose.

The v2 error envelope

Every API v2 error response has this shape:

{
  "error": {
    "code": "VALIDATION_INVALID_BODY",
    "message": "message is required and must be a non-empty string",
    "details": {}
  }
}
  • code — a stable, screaming-snake-case identifier. Branch on this.
  • message — a human-readable explanation. May change; do not match on it.
  • details — present only on some errors (for example field-level validation issues).

The HTTP status reflects the class of error; the code gives the specific reason.

Common codes

StatusCodeWhen
400VALIDATION_INVALID_BODYA required field is missing or a field failed validation (e.g. empty message, malformed userId).
401AUTH_MISSING_API_KEYNo Authorization: Bearer header.
401AUTH_INVALID_API_KEYUnknown, malformed, or revoked key.
403AUTH_INSUFFICIENT_PERMISSIONSAn agent-scoped key targeting a different agent.
404RESOURCE_NOT_FOUNDThe agent or conversation does not exist or is not in your workspace.
404RESOURCE_MESSAGE_NOT_FOUNDThe referenced message does not exist in the conversation.
404RESOURCE_TOOL_CALL_NOT_FOUNDNo pending tool call matched the supplied toolCallId.
400RESOURCE_MESSAGE_NOT_ASSISTANTFeedback was sent for a non-assistant message.
400CHAT_RETRY_NO_USER_MESSAGEA retry was requested but there is no user turn to retry from.
404CHAT_RETRY_MESSAGE_NOT_FOUNDThe messageId to retry was not found in the conversation.
429RATE_LIMIT_TOO_MANY_REQUESTSThe per-key rate limit was exceeded.
500INTERNAL_SERVER_ERRORAn unexpected server error. Safe to retry with backoff.

Rate limiting

API v2 is rate limited per API key using a sliding window of 100 requests per 10 seconds. Every v2 response carries the current limit state in headers:

HeaderMeaning
X-RateLimit-LimitThe window ceiling (100).
X-RateLimit-RemainingRequests left in the current window.
X-RateLimit-ResetUnix-ms timestamp when the window resets.

When the limit is exceeded you receive 429 with code RATE_LIMIT_TOO_MANY_REQUESTS. Back off (roughly one second) and retry.

tip

Treat 429 and 5xx as retryable. Retry with exponential backoff and a little jitter; do not retry 4xx validation or auth errors — fix the request instead.

The v1 (Chatbase-compatible) error body

The Chatbase-parity contacts and custom-attributes endpoints under /api/v1/chatbots/... use the conventional status codes but a simpler body containing only a message:

{ "message": "Resource not found" }
StatusExample messageWhen
400Invalid request dataMissing or malformed body (e.g. no users array on create).
401No API key provided. / Invalid API key.Missing or invalid Bearer key.
404Resource not foundUnknown chatbot/contact/attribute, or out of your workspace.
409External ID or email already exists.A uniqueness conflict on external_id.

The legacy v1 chat stream (POST /api/v1/chat) reports validation and not-found errors as JSON { success: false, error: { code, message } } before the SSE stream opens. See Chat with an agent (v1).