> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://poly-ai.ferndocs.com/_mcp/server. # Messaging API ## Docs - [Messaging API](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/overview.md): Embed real-time text conversations into your application using WebSockets, with handoff to live agents. - [Sessions and authentication](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/sessions-and-authentication.md): Exchange your connector token for a short-lived access token, then create a session. - [WebSocket connection](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/web-socket-connection.md): Connect, reconnect, and keep the WebSocket alive. - [Event format](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/event-format.md): The common JSON envelope used for every WebSocket event. - [Client events](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/client-events.md): Events your client can send over the WebSocket. - [Server events](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/server-events.md): Events your client receives over the WebSocket. - [Streaming](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/streaming.md): Receive agent responses as incremental chunks, like ChatGPT's typing effect. - [Handoff to live agent](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/handoff-to-live-agent.md): Transfer the conversation from the PolyAI agent to a human agent. - [Session lifecycle](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/session-lifecycle.md): Every event in order, from connection through session end. - [Errors](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/errors.md): HTTP status codes and system-message error catalog. - [Best practices](https://poly-ai.ferndocs.com/api-reference/runtime-data/messaging-api/best-practices.md): Recommendations for connection management, message handling, UX, and security.