Visit the integrations homepage if you are looking for more information on Webchat integrations.
Chatting with the API
-
Start a conversation
Send a
POST /chat/create
request with:- a unique
user_id
(UUID recommended) - an optional
message
(can be an empty string) - an empty or populated
metadata
object
conversation_id
and the assistant’s initial message. - a unique
-
Send and receive messages
Use
POST /chat/respond
with theconversation_id
and amessage
. The response includes the assistant’s reply and an optionalend_conversation
flag.
Endpoints
Base URLs
The Chat API is available in the following regions:Region | Base URL |
---|---|
US | https://api.us-1.platform.polyai.app |
UK | https://api.uk-1.platform.polyai.app |
EU-W | https://api.euw-1.platform.polyai.app |
/v1/{account_id}/{project_id}/chat/{operation}
account_id
: Your PolyAI account ID (e.g.poly-scs-uk
)project_id
: Your PolyAI project ID (e.g.PROJECT-191bfa2a
)operation
: Eithercreate
orrespond
Authentication
All requests must include the following headers:Header | Description |
---|---|
X-Api-Key | Your API key for PolyAI |
X-Token | A token identifying the agent (connector token) |
Content-Type | Must be application/json |
Example: Create Chat
POST/v1/poly-scs-uk/PROJECT-191bfa2a/chat/create
Body:
Example: Send Message
POST/v1/poly-scs-uk/PROJECT-191bfa2a/chat/respond
Body:
Notes
user_id
must be unique per session. Useuuid.uuid4()
to generate it safely.conversation_id
must match the ID returned by the/chat/create
endpoint.end_conversation
indicates the assistant has concluded the session.- All fields in the request bodies are required (even if some are empty).