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:
| Cluster | Base URL | Description |
|---|---|---|
us-1 | https://messaging.us-1.poly.ai | US Mainland |
uk-1 | https://messaging.uk-1.poly.ai | UK |
euw-1 | https://messaging.euw-1.poly.ai | EU West |
Prerequisites
Before integrating, you need two values, both generated in Agent Studio under Messaging → API Configuration:| Value | What it is | Where to find it |
|---|---|---|
| Connector token | A secret token that identifies your integration | Generated in the Messaging API Key section of API Configuration in Agent Studio |
| Host identifier | The domain (e.g. https://www.yourcompany.com) or app namespace (e.g. com.yourcompany.app) you registered when generating the token | Set during token generation in Agent Studio. The server rejects requests where X-Host doesn’t match. |
The API Configuration page also has a section for generating a shared signing key for context injection — that’s a separate feature and not covered here.
Getting started
Every conversation follows this sequence:Obtain an access token
POST /api/v1/access-token with your connector token. Returns a short-lived JWT.Minimal JavaScript example
Messaging API vs Chat API
PolyAI offers two APIs for non-voice channels. Pick the one that matches your integration model.| Messaging API | Chat API | |
|---|---|---|
| Protocol | WebSocket (real-time, event-driven) | REST (turn-based request/response) |
| Streaming responses | Yes (incremental chunks) | No |
| Typing indicators | Yes | No |
| Live-agent handoff | Yes (full event flow over the WebSocket) | Yes (via handoff in the respond response) |
| Reconnection / history replay | Built-in (cursor query param) | Client manages turns |
| Auth | Connector token + host domain → short-lived JWT | API key + connector token |
| Best for | Web apps, iOS/Android apps, custom SDKs | SMS, server-to-server, simple webchat |
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

