Error Handling
How to handle API errors gracefully.
All error responses follow a consistent format:
HTTP Status Codes
| Status | Meaning | When |
|---|---|---|
400 | Bad Request | Missing required fields or invalid data |
401 | Unauthorized | Missing or invalid API key |
404 | Not Found | Agent, session, or resource doesn't exist |
500 | Internal Server Error | Unexpected server-side error |
Common Errors
401 — Unauthorized
Causes:
X-API-Keyheader is missing- API key is malformed (must start with
api_) - API key has been revoked or expired
- API key doesn't exist
Fix: Check your API key is correct and hasn't expired.
404 — Agent Not Found
Causes:
- The agent ID is incorrect
- The agent is not in
PUBLISHEDstate - The agent belongs to a different organisation
Fix: Use GET /agents to list valid agent IDs.
404 — Session Not Found
Causes:
- The session ID is incorrect
- The session was deleted
- The session belongs to a different agent
400 — Missing Message
Fix: Ensure the message field is present and non-empty in the request body.