Skip to main content

Exception Hierarchy

All SDK errors extend ChatbaseException:

ApiException

class ApiException : ChatbaseExceptionPackage: com.chatbase.sdk.exception Thrown when the Chatbase API returns an error response.
Int
required
The HTTP status code of the error response (e.g. 401, 403, 429).
String
required
Machine-readable error code. Use this for programmatic handling.
String
required
Human-readable error description.
Map<String, String>?
Optional field-level validation errors.

Convenience Properties

For statuses without a helper — such as 401 (authentication) or 403 (access denied) — check httpStatus or errorCode directly.

Error Codes

These are the error codes you may encounter through ApiException.errorCode:
StatusCodeDescription
400VALIDATION_INVALID_BODYThe request body failed validation. details maps field names to messages. Also returned when a tool result exceeds the 20 KB limit.
400CHAT_RETRY_NO_USER_MESSAGEThe message passed to retry() has no preceding user message to retry from.
401AUTH_INVALID_JWTThe JWT token passed to identify() is invalid, expired, or could not be verified — including when identity verification is not configured for the agent. See User Identity.
402CHAT_CREDITS_EXHAUSTEDThe workspace’s message credit balance is zero. Upgrade the plan or wait for credits to reset. Caught by isCreditsExhausted.
402CHAT_AGENT_CREDITS_EXHAUSTEDThe specific agent’s credit allocation has been used up. Caught by isCreditsExhausted.
403AUTH_OWNERSHIP_MISMATCHThe conversation belongs to a different user or device. Also returned by retry() and listMessages() when the conversation does not exist.
403CHAT_CONVERSATION_MISMATCHThe conversation could not be resolved for this agent.
403CHAT_MODEL_NOT_ALLOWEDThe agent uses a model not available on the current plan.
403CHAT_CONVERSATION_NOT_ONGOINGThe conversation has ended or was taken over and cannot receive new messages. Start a new conversation.
404AGENT_NOT_FOUNDNo agent matches the provided ID, or the Android SDK channel is not enabled for the agent (see Quick Start). Caught by isNotFound.
404RESOURCE_NOT_FOUNDThe conversation or message does not exist. Caught by isNotFound.
404CHAT_RETRY_MESSAGE_NOT_FOUNDThe message ID provided for retry() was not found. Caught by isNotFound.
404RESOURCE_TOOL_CALL_NOT_FOUNDThe tool call was not found or has expired. Can surface through the automatic tool loop. Caught by isNotFound.
404RESOURCE_TOOL_CALL_MISMATCHThe tool call does not belong to this conversation. Caught by isNotFound.
404RESOURCE_TOOL_RESULT_NOT_PENDINGNo pending tool result exists for this tool call — usually a duplicate submission. Caught by isNotFound.
429RATE_LIMIT_TOO_MANY_REQUESTSRate limit exceeded (1,000 requests per 10 seconds per device). Back off and retry. Caught by isRateLimited.
500CHAT_STREAMING_ERRORThe response stream failed server-side. Safe to retry.
500INTERNAL_SERVER_ERRORAn unexpected server error occurred. Retry, or contact support if it persists.

NetworkException

class NetworkException : ChatbaseExceptionPackage: com.chatbase.sdk.exception
Thrown for connection-level failures — DNS errors, socket timeouts, no internet connectivity, and similar issues.

Handling Errors

Use a try-catch block with the SDK’s exception hierarchy:

Streaming

Streaming callbacks and error events

Overview

SDK setup and configuration