The Messaging API is a real-time, event-driven protocol. If you only need simple turn-based request/response (for example for SMS), use the Chat API instead. See Messaging API vs Chat API below.
Base URL
https://messaging.<cluster>.poly.ai:
Your PolyAI contact will confirm which base URL to use.
Prerequisites
Before integrating, you need two values:The self-serve Messaging → API Configuration page in Agent Studio is not fully built out yet. For now, your PolyAI representative will provision a connector token and register the host identifier on your behalf.
Getting started
Every conversation follows this sequence:1
Obtain an access token
POST /api/v1/access-token with your connector token. Returns a short-lived JWT.2
Create a session
POST /api/v1/sessions with the access token. Returns a session_id.3
Open a WebSocket connection
wss://<base-url>/ws?access_token=...&session_id=...4
Request the agent to join
Send
EVENT_TYPE_REQUEST_POLY_AGENT_JOIN to start the conversation.5
Exchange messages
Send and receive events over the WebSocket.
Minimal JavaScript example
Messaging API vs Chat API
PolyAI offers two APIs for non-voice channels. Pick the one that matches your integration model.Reference
Sessions and authentication
Obtain an access token and create a session
WebSocket connection
Connect, reconnect, and keep the connection alive
Event format
Common envelope, echo behavior, delivery receipts
Client events
Events your client can send
Server events
Events your client receives
Streaming
Receive agent responses as incremental chunks
Handoff to live agent
Server-managed and client-managed handoff flows
Session lifecycle
Every event in order, from connect to session end
Errors
HTTP codes and system-message error catalog
Best practices
Connection management, dedup, ordering, UX, security

