Newer Version Available
Getting Started with the Chat REST API
Retrieve Your Chat API Endpoint
- From Setup, in the Quick Find box, enter Chat Settings, and then select Chat Settings.
- Retrieve the hostname from the Chat API Endpoint. The hostname is the URL without “/chat/rest/” at the end, for example, “https://yourChatApiEndpoint.com”. Substitute hostname in the Chat API endpoints with this URL.
Start a Chat Session
To start a Chat session, send a SessionId request. Replace hostname with the URL that you retrieved from Chat API Endpoint.
- X-LIVEAGENT-AFFINITY
- X-LIVEAGENT-API-VERSION
Confirm the Chat Session Started
A ChatRequestSuccess response tells you that the Chat session started.
Then wait for a ChatEstablished response. That response tells you that an agent accepted the chat session.
Now you’re ready to send, for example, Messages requests. Before you send further requests, wait until you receive the ChatRequestSuccess and ChatEstablished responses, otherwise the API throws a Null Pointer exception, and you receive a 500 error.
End the Chat Session
The Chat session ends when you send a ChatEnd request or send a DELETE SessionId request. In both request types, X-LIVEAGENT-SESSION-KEY is the unique ID of the Chat session that you want to end.
Here’s the ChatEnd request.
- X-LIVEAGENT-AFFINITY
- X-LIVEAGENT-API-VERSION
- X-LIVEAGENT-SESSION-KEY
- X-LIVEAGENT-SEQUENCE
Here’s the SessionId request.
- X-LIVEAGENT-AFFINITY
- X-LIVEAGENT-API-VERSION