Skip to main content

HTTP errors

WebSocket errors

If you send an invalid event (wrong type, malformed JSON, or a server-only event type), the server responds with EVENT_TYPE_SYSTEM_MESSAGE at level SYSTEM_MESSAGE_LEVEL_ERROR. The message describes what went wrong. Your WebSocket connection remains open — fix the issue and continue.

Rate limiting

Both HTTP endpoints and WebSocket messages are rate limited per session.
  • HTTP: returns 429 Too Many Requests with a Retry-After header
  • WebSocket: messages may be dropped
Under normal usage you should not hit rate limits.

Access token errors

Returned from POST /api/v1/access-token.

Session creation errors

Returned from POST /api/v1/sessions.

WebSocket connection errors

Returned as HTTP errors during the WebSocket handshake, not as WebSocket events.
An invalid cursor value (for example, a non-numeric string) does not reject the connection. The server logs a warning and defaults to 0, replaying the full conversation history.

Invalid event errors

These arrive as EVENT_TYPE_SYSTEM_MESSAGE events. The connection remains open.

Agent errors

These arrive as EVENT_TYPE_SYSTEM_MESSAGE during the conversation. They indicate a server-side issue — your client did nothing wrong.

Session state errors

These usually mean the session has expired or the server has lost track of it.

Handoff errors

General debugging tips

  • Check metadata.custom. Custom metadata you sent is echoed back in error messages too — useful for correlating errors with specific user actions.
  • Watch for SESSION_END after errors. Some errors are followed by a SESSION_END event. Always handle session end gracefully.
  • “High load” errors are transient. They self-resolve — implement a brief retry (2–5 seconds) before showing a permanent error.
  • Connection dropped ≠ session ended. Reconnect with the same session_id and a cursor to resume.
  • Log the full event. When reporting issues to PolyAI, include the complete JSON of the error event (including id, timestamp, and metadata).
Last modified on June 18, 2026