chat_rest
chat_rest
names and marks. Other marks appearing herein may be trademarks of their respective owners.
CONTENTS
Chapter 1: Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 5: Using Estimated Wait Time Instead of Queue Position for a Chat Session
(Beta) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
CHAPTER 1 Overview
Take Chat to a native mobile app or a custom client using the Chat REST API.
EDITIONS
Note: The legacy chat product is scheduled for retirement on February 14, 2026, and is in
maintenance mode until then. During this phase, you can continue to use chat, but we no Available in: Salesforce
longer recommend that you implement new chat channels. To avoid service interruptions Classic and Lightning
Experience
to your customers, migrate to Messaging for In-App and Web. Messaging offers many of the
chat features that you love plus asynchronous conversations that can be picked back up at Available in: Performance
any time. Learn about chat retirement in Help. Editions and in Developer
You don’t have to rely on Visualforce to develop customized chat windows. With the REST resources Edition orgs that were
in this guide, you can extend the functionality of chat windows beyond simple HTML and JavaScript created after June 14, 2012
environments that merge seamlessly into your company’s own applications. Available in: Essentials,
Unlimited, and Enterprise
Note: Chat REST API doesn’t support building custom clients that work with Einstein Bots. Editions with Service Cloud
See Einstein Bots API and SDK. or Sales Cloud
SEE ALSO:
Embedded Service SDK for iOS Developer Guide
Embedded Service SDK for Android Developer Guide
1
CHAPTER 2 Getting Started with the Chat REST API
Learn how to start, confirm, and end a Chat session with the Chat REST API.
Note: The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During
this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service
interruptions to your customers, migrate to Messaging for In-App and Web. Messaging offers many of the chat features that you
love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.
GET https://hostname/chat/rest/System/SessionId/
2
Getting Started with the Chat REST API
geoLocation: {
countryCode:"US",
countryName: "United States of America",
region: "CA",
city: "San Francisco",
organization: Salesforce,
latitude: 37.793880,
longitude: -122.395114
},
url: "http://yoursite",
oref: "http://www.google.com?q=yoursite",
postChatUrl: "http://yoursite/postchat",
customDetails: [
{
label: "E-mail Address",
value: "[email protected]",
transcriptFields: [
"c__EmailAddress"
],
displayToAgent: true
}
],
visitorId: "acd47048-bd80-476e-aa33-741bd5cb05d3"
}
Then wait for a ChatEstablished on page 22 response. That response tells you that an agent accepted the chat session.
{
name: "Andy L.",
userId: "f1dda237-57f8-4816-b8e8-59775f1e44c8",
sneakPeekEnabled: true
}
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.
https://hostname/chat/rest/Chasitor/ChatEnd
3
Getting Started with the Chat REST API
DELETE https://hostname/chat/rest/System/SessionId/X-LIVEAGENT-SESSION-KEY
4
CHAPTER 3 Request Headers
Each Chat REST API resource requires one or more headers to make a request.
Note: The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During
this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service
interruptions to your customers, migrate to Messaging for In-App and Web. Messaging offers many of the chat features that you
love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.
Not all resources require all of the available request headers. Each resource indicates which headers are required to make a request.
The following headers are available:
X-LIVEAGENT-AFFINITY The system-generated ID used to identify the Chat session on the Chat servers. This
affinity token is included in the response body of the SessionId request.
Note: Your session key shouldn’t be shared or sent over insecure channels, as it
allows access to potentially sensitive chat information.
X-LIVEAGENT-SEQUENCE The sequence of messages you have sent to the Chat server to help the Chat server avoid
processing duplicate messages. This number should be increased by one with every
new request.
5
CHAPTER 4 Your Message Long Polling Loop
Message long polling notifies you of events that occur on the Chat server for your Chat session.
Note: The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During
this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service
interruptions to your customers, migrate to Messaging for In-App and Web. Messaging offers many of the chat features that you
love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.
When you start a request, all pending messages get immediately delivered to your session. If there are no pending messages, the
connection to the server will remain open. The Messages poll will return one payload of messages from the server when they become
available, and you’ll have to open a new Messages connection to receive future data.
You’ll receive a 200 (“OK”) response code and a resource that contains an array of the remaining messages. If no messages were received,
you will receive a 204 (“No Content”) response code.
When you receive a 200 (“OK”) or 204 (“No Content”) response code, immediately perform another Messages request to continue
to retrieve messages that are registered on the Chat server.
Warning: If you don’t make another Messages request to continue the messaging loop, your session will end after a system
timeout on the Chat server.
If you don’t receive a response within the number of seconds indicated by the clientPollTimeout property in your SessionId
request, your network connection to the server is likely experiencing an error, so you should terminate the request.
To initiate a long polling loop, perform a Messages request.
SEE ALSO:
Messages
SessionId
Status Codes and Error Responses
6
CHAPTER 5 Using Estimated Wait Time Instead of
Queue Position for a Chat Session (Beta)
By default, the Chat API returns queue position information that you can relay to customers. However,
you can also receive the estimated wait time in addition to the queue position. Sometimes, the estimated
wait time more effectively conveys the right information to customers than a queue position number.
This feature is available in API version 47.0 and later.
Note: The legacy chat product is scheduled for retirement on February 14, 2026, and is in
maintenance mode until then. During this phase, you can continue to use chat, but we no longer
recommend that you implement new chat channels. To avoid service interruptions to your
customers, migrate to Messaging for In-App and Web. Messaging offers many of the chat features
that you love plus asynchronous conversations that can be picked back up at any time. Learn about
chat retirement in Help.
Note: As a beta feature, Estimated Wait Time is a preview and isn’t part of the “Services” under
your main subscription agreement with Salesforce. Use this feature at your sole discretion, and
make your purchase decisions only on the basis of generally available products and features.
Salesforce doesn’t guarantee general availability of this feature within any particular time frame
or at all, and we can discontinue it at any time. This feature is for evaluation purposes only, not for
production use. It’s offered as is and isn’t supported, and Salesforce has no liability for any harm
or damage arising out of or in connection with it. All restrictions, Salesforce reservation of rights,
obligations concerning the Services, and terms for related Non-Salesforce Applications and Content
apply equally to your use of this feature.
The following algorithm is used to calculate the wait time:
A = (0.9 * A′) + (0.1 * W)
Where:
• A′ is the previous value for A. If no previous value exists, this value is W.
• W is the wait time of the chat that has most recently been accepted.
The value returned is the value of A minus the time already spent waiting.
Additional algorithm details:
• This value is calculated separately for each chat button.
• A is recalculated each time a chat is accepted.
• 0 is returned if the result is less than 0.
• -1 is returned when the value cannot be calculated.
To use this feature, specify that you want the estimated wait time from the Settings request (by setting
Settings.needEstimatedWaitTime to 1) and the Availability request (by setting
Availability.needEstimatedWaitTime to 1). When this value is set to 1, the response
includes the estimated wait time for each button ID requested.
If receiveQueueUpdates is set when initializing the session, ChatRequestSuccess and QueueUpdate
will both contain the estimated wait time (in seconds) in their responses.
7
CHAPTER 6 Chat REST API Resources
To perform a POST or GET request, create and send an HTTP request with the appropriate parameters or request body.
Note: The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During
this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service
interruptions to your customers, migrate to Messaging for In-App and Web. Messaging offers many of the chat features that you
love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.
The Chat REST API requests let you begin new chat sessions between agents and chat visitors and monitor the chat activity that occurs.
IN THIS SECTION:
Create a Chat Session
To create a new Chat session, you must call the SessionId request.
Create a Chat Visitor Session
To create or reestablish a chat visitor session using the Chat REST API, you must make certain requests.
Monitor Chat Activity
Chat requests indicate when certain activities occurred during a chat session.
Customize the Chat Visitors’ Experience
With the Chat visitor REST API resources, you can establish your chat visitors’ experience with Chat in custom mobile applications.
IN THIS SECTION:
SessionId
Establishes a new Chat session. The SessionId request is required as the first request to create every Chat session.
SessionId
Establishes a new Chat session. The SessionId request is required as the first request to create every Chat session.
Syntax
URI
https://hostname/chat/rest/System/SessionId/
https://hostname/chat/rest/System/SessionId/X-LIVEAGENT-SESSION-KEY
Available since release
This resource is available in API versions 29.0 and later.
8
Chat REST API Resources Create a Chat Visitor Session
Formats
JSON
HTTP methods
GET—Creates a session. Don't pass X-LIVEAGENT-SESSION-KEY to the URL.
DELETE—Deletes the session. Pass X-LIVEAGENT-SESSION-KEY, the session key, to the URL.
Request headers
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-API-VERSION
Request body
None
Request parameters
None
Response Body
SessionId response
SEE ALSO:
Your Message Long Polling Loop
IN THIS SECTION:
ChasitorInit
Initiates a new chat visitor session. The ChasitorInit request is always required as the first POST request in a new chat session.
ReconnectSession
Reconnect a customer’s chat session on a new server if the session is interrupted and the original server is unavailable.
ChasitorResyncState
Reestablishes the chat visitor’s state, including the details of the chat, after a ReconnectSessionrequest is completed.
ChasitorInit
Initiates a new chat visitor session. The ChasitorInit request is always required as the first POST request in a new chat session.
Syntax
URI
https://hostname/chat/rest/Chasitor/ChasitorInit
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
9
Chat REST API Resources ReconnectSession
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
X-LIVEAGENT-SEQUENCE
Request parameters
None
Query parameters
None
Request body
ChasitorInit request
Response body
None
ReconnectSession
Reconnect a customer’s chat session on a new server if the session is interrupted and the original server is unavailable.
This request should only be made if you receive a 503 response status code, indicating that the affinity token has changed for your Chat
session. When you receive a 503 response status code, you must cancel any existing inbound or outbound requests.
The data in outbound requests will be temporarily stored and resent once the session is reestablished. Upon receiving the response for
the ReconnectSession request, you can start polling for messages.
The first response will be a ChasitorSessionData message containing the data from the previous session that will be restored
once the session is reestablished. After receiving that message, you can proceed to send the existing messages that were canceled upon
receiving the 503 response status code.
Syntax
URI
https://hostname/chat/rest/System/ReconnectSession
Available since release
This resource is available in API versions 37.0 and later.
Formats
JSON
HTTP methods
GET
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
10
Chat REST API Resources ReconnectSession
Request parameters
Query parameters
None
Request body
None
Response body
ReconnectSession
Example: Your REST client can get a 503 Invalid Affinity Token response, for example, to a long poll request
(/chat/rest/System/Messages).
No matter which kind of request gets the 503 response, you must send a /chat/rest/System/ReconnectSession
request to finish the handover process.
Method: GET
URL:
<!-- Change the live agent pool to the correct one for your org. -->
https://LiveAgentPool.salesforceliveagent.com/chat/rest/System/
ReconnectSession?ReconnectSession.offset=54647226
Headers:
X-LIVEAGENT-AFFINITY:
null [the literal string “null”]
X-LIVEAGENT-API-VERSION:
42
X-LIVEAGENT-SESSION-KEY:
4eb90106-3410-4dd0-8f04-c4facf90a929!1519169434766!IbjEwmJkIIyqalZS3YBU8WO3nSM=
The ReconnectSession.offset query parameter has to be set to the “offset” parameter of the most recent long poll
response that actually contained messages. Empty long poll responses don’t come with an “offset”.
The response to this ReconnectSession request looks like this:
{
"messages": [
{
"type": "ReconnectSession",
"message": {
"resetSequence": true, [This may be undefined]
"affinityToken": "efae1fa0"
}
}
]
}
11
Chat REST API Resources ChasitorResyncState
The resetSequence is always set to true. Therefore, reset the sequence number of the next request and store the value in
affinityToken to use in the X-LIVEAGENT-AFFINITY header for all future requests. Once another handover process
occurs the resetSequence is updated again.
Testing
To test that your client handles this process correctly, check that your client sends a ReconnectSession request when it receives a 503
response from the server. You can use a proxy tool of your choice to mimic the 503 response or you can wait until the Salesforce server
sends one. When the proxy tool sends a 503 response, you can test that your client sends the ReconnectSession request and reconnects
the chat session to a new server, as expected. To get an actual 503 response from the server, you can leave a session connected and
wait until the server is restarted during scheduled maintenance. Then see if the chat session reconnects to a new server. However, the
maintenance schedule is not announced in advance.
SEE ALSO:
Status Codes and Error Responses
ChasitorSessionData
ChasitorResyncState
Status Codes and Error Responses
ChasitorResyncState
Reestablishes the chat visitor’s state, including the details of the chat, after a ReconnectSessionrequest is completed.
Syntax
URI
https://hostname/chat/rest/Chasitor/ChasitorResyncState
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
Request parameters
None
Query parameters
None
Request body
ChasitorResyncState request
12
Chat REST API Resources Monitor Chat Activity
Response body
None
SEE ALSO:
ReconnectSession
IN THIS SECTION:
ChasitorNotTyping
Indicates that the chat visitor is not typing in the chat window.
ChasitorSneakPeek
Provides a chat visitor’s message that was viewable through Sneak Peek.
ChasitorTyping
Indicates that a chat visitor is typing a message in the chat window.
ChatEnd
Indicates that a chat visitor has ended the chat.
ChatMessage
Returns the body of the chat message sent by the chat visitor.
CustomEvent
Indicates a custom event was sent from the chat visitor during the chat.
Messages
Returns all messages that were sent between agents and chat visitors during a chat session.
MultiNoun
Batches multiple POST requests together if you’re sending multiple messages at the same time.
ChasitorNotTyping
Indicates that the chat visitor is not typing in the chat window.
Syntax
URI
https://hostname/chat/rest/Chasitor/ChasitorNotTyping
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
13
Chat REST API Resources ChasitorSneakPeek
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
X-LIVEAGENT-SEQUENCE
Request parameters
None
Query parameters
None
Request body
None
Response body
None
ChasitorSneakPeek
Provides a chat visitor’s message that was viewable through Sneak Peek.
Syntax
URI
https://hostname/chat/rest/Chasitor/ChasitorSneakPeek
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
X-LIVEAGENT-SEQUENCE
Request parameters
None
Query parameters
None
Request body
ChasitorSneakPeek request
Response body
None
14
Chat REST API Resources ChasitorTyping
ChasitorTyping
Indicates that a chat visitor is typing a message in the chat window.
Syntax
URI
https://hostname/chat/rest/Chasitor/ChasitorTyping
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
X-LIVEAGENT-SEQUENCE
Request parameters
None
Query parameters
None
Request body
None
Response body
None
ChatEnd
Indicates that a chat visitor has ended the chat.
Syntax
URI
https://hostname/chat/rest/Chasitor/ChatEnd
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
15
Chat REST API Resources ChatMessage
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
X-LIVEAGENT-SEQUENCE
Request parameters
None
Query parameters
None
Request body
ChatEndReason—Include the ChatEndReason parameter in the request body of your request to specify the reason that
the chat ended. This parameter is required. For example: {reason: “client”}.
Response properties
attachedRecords—Includes attached record IDs. You can use this Visualforce component to display the attached record IDs
in the post-chat page: <apex:outputText value=”{!$CurrentPage.parameters.attachedRecords}”/><br
/>.
ChatMessage
Returns the body of the chat message sent by the chat visitor.
Syntax
URI
https://hostname/chat/rest/Chasitor/ChatMessage
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
X-LIVEAGENT-SEQUENCE
Request parameters
None
Query parameters
None
Request body
ChatMessage request
16
Chat REST API Resources CustomEvent
Response body
None
CustomEvent
Indicates a custom event was sent from the chat visitor during the chat.
Syntax
URI
https://hostname/chat/rest/Chasitor/CustomEvent
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
X-LIVEAGENT-SEQUENCE
Request parameters
None
Query parameters
None
Request body
CustomEvent request
Response body
None
Messages
Returns all messages that were sent between agents and chat visitors during a chat session.
For a complete list of responses for the Messages resource, see Chat REST API Messages Response Objects.
Syntax
URI
https://hostname/chat/rest/System/Messages
Available since release
This resource is available in API versions 29.0 and later.
17
Chat REST API Resources Messages
Formats
JSON
HTTP methods
GET
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
Request parameters
None
Query parameters
ack—The ack query parameter is a sequencing mechanism that allows you to poll for messages on the Live Agent server. The
first time you make the Messages request, the ack parameter is set to –1. To guarantee that you receive the messages from
the server in the correct order, update the ack value in the next request with the sequence value from the preceding response.
You receive a sequence value only if the response code is 200, which is the response if there are new messages. If the response
code is 204, there are no messages and the client doesn't provide a sequence value. In this case, run the Messages request
with the same ack value as the previous request.
Request body
None
Response body
Messages response
Troubleshooting
If your request doesn’t receive an HTTP response and fails, retry the request. If you don’t retry the request before the chat session times
out, the session expires. The timeout value that determines how long you have to attempt to send requests before the server expires
the session is configured in Chat Deployment in Salesforce Setup.
IN THIS SECTION:
Chat REST API Messages Response Objects
The Messages request returns an array of objects that represent all the events that occurred during an agent’s chat with a chat
customer.
SEE ALSO:
Your Message Long Polling Loop
18
Chat REST API Resources Messages
IN THIS SECTION:
AgentDisconnect
Indicates that the agent has been disconnected from the chat.
AgentNotTyping
Indicates that the agent is not typing a message to the chat visitor.
AgentTyping
Indicates that the agent is typing a message to the chat visitor.
ChasitorSessionData
Returns the current chat session data for the chat visitor. This request is used to restore the session data for a chat visitor’s chat session
after a ReconnectSessionrequest is sent.
ChatEnded
Indicates that the chat has ended.
19
Chat REST API Resources Messages
ChatEstablished
Indicates that an agent has accepted a chat request and is engaged in a chat with a visitor.
ChatMessage
Indicates a new chat message has been sent from an agent to a chat visitor.
ChatRequestFail
Indicates that the chat request was not successful.
ChatRequestSuccess
Indicates that the chat request was successful and routed to available agents.
ChatTransferred
Indicates the chat was transferred from one agent to another.
CustomEvent
Indicates a custom event was sent from an agent to a chat visitor during a chat.
NewVisitorBreadcrumb
Indicates the URL of the Web page the chat visitor is currently viewing.
QueueUpdate
Indicates the new position of the chat visitor in the chat queue when the visitor’s position in the queue changes.
SensitiveDataRules
Lists the sensitive data rules.
AgentDisconnect
Indicates that the agent has been disconnected from the chat.
Note: Though the agent has been disconnected from the chat, the chat session is still active on the server. A new agent may
accept the chat request and continue the chat.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
None
Response properties
None
AgentNotTyping
Indicates that the agent is not typing a message to the chat visitor.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
None
20
Chat REST API Resources Messages
Response properties
None
AgentTyping
Indicates that the agent is typing a message to the chat visitor.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
None
Response properties
None
ChasitorSessionData
Returns the current chat session data for the chat visitor. This request is used to restore the session data for a chat visitor’s chat session
after a ReconnectSessionrequest is sent.
The ChasitorSessionData request is the first message sent after a ReconnectSession request is delivered.
Note: No messages should be sent after a 503 status code is encountered until this message is processed.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
ChasitorSessionData response
SEE ALSO:
ReconnectSession
Status Codes and Error Responses
Status Codes and Error Responses
ChatEnded
Indicates that the chat has ended.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
ChatEndReason on page 38 response
21
Chat REST API Resources Messages
Response properties
None
ChatEstablished
Indicates that an agent has accepted a chat request and is engaged in a chat with a visitor.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
ChatEstablished response
SEE ALSO:
ChatRequestSuccess
ChatMessage
Indicates a new chat message has been sent from an agent to a chat visitor.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
ChatMessage response
ChatRequestFail
Indicates that the chat request was not successful.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
ChatRequestFail response
ChatRequestSuccess
Indicates that the chat request was successful and routed to available agents.
Note: The ChatRequestSuccess response only indicates that a request has been routed to available agents. The chat
hasn’t been accepted until the ChatEstablished response is received.
22
Chat REST API Resources Messages
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
ChatRequestSuccess response
SEE ALSO:
ChatEstablished
ChatTransferred
Indicates the chat was transferred from one agent to another.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
ChatTransferred response
CustomEvent
Indicates a custom event was sent from an agent to a chat visitor during a chat.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
CustomEvent response
NewVisitorBreadcrumb
Indicates the URL of the Web page the chat visitor is currently viewing.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
NewVisitorBreadcrumb response
QueueUpdate
Indicates the new position of the chat visitor in the chat queue when the visitor’s position in the queue changes.
23
Chat REST API Resources MultiNoun
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
QueueUpdate response
SensitiveDataRules
Lists the sensitive data rules.
Syntax
Available since release
This resource is available in API versions 29.0 and later.
Response body
SensitiveDataRules response
Response properties
None
MultiNoun
Batches multiple POST requests together if you’re sending multiple messages at the same time.
Syntax
URI
https://hostname/chat/rest/System/MultiNoun
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
X-LIVEAGENT-AFFINITY
X-LIVEAGENT-SESSION-KEY
X-LIVEAGENT-SEQUENCE
Request parameters
None
Query parameters
None
Request body
MultiNoun request
24
Chat REST API Resources Customize the Chat Visitors’ Experience
Response body
None
IN THIS SECTION:
Settings
Retrieves all settings information about the Chat deployment that’s associated with your chat session. The Settings request is
required as the first request to establish a chat visitor’s session.
Availability
Indicates whether a chat button is available to receive new chat requests.
Breadcrumb
Sets a breadcrumb value to the URL of the Web page that the chat visitor is viewing as the visitor chats with an agent. The agent
can then see the value of the breadcrumb to determine the page the chat visitor is viewing.
VisitorId
Generates a unique ID to track a chat visitor when they initiate a chat request and tracks the visitor’s activities as the visitor navigates
from one Web page to another.
SensitiveDataRuleTriggered for Agents
Sets the sensitive data rules for the chat agent, such as blocking the agent’s credit card, Social Security, phone and account numbers,
or even profanity.
SensitiveDataRuleTriggered for Chasitors
Sets the sensitive data rules for the chat visitor, such as blocking the visitor’s credit card, Social Security, phone and account numbers,
or even profanity.
Settings
Retrieves all settings information about the Chat deployment that’s associated with your chat session. The Settings request is
required as the first request to establish a chat visitor’s session.
Syntax
URI
https://hostname/chat/rest/Visitor/Settings
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
GET
Request headers
X-LIVEAGENT-API-VERSION
25
Chat REST API Resources Availability
Request parameters
None
Query parameters
org_id
The ID of the Salesforce organization that’s associated with the Live Agent deployment.
deployment_id
The ID of the Chat deployment that the chat request was initiated from.
Settings.buttonIds
An array of chat button IDs for which to retrieve settings information.
Settings.needEstimatedWaitTime
Indicates whether the estimatedWaitTime property should be filled. Specify a value of 1 to request the estimated wait
time.
Settings.updateBreadcrumb
Indicates whether to update the chat visitor’s location with the URL of the Web page that the visitor is viewing.
Request body
None
Response body
Settings response on page 46
Availability
Indicates whether a chat button is available to receive new chat requests.
Syntax
URI
https://hostname/chat/rest/Visitor/Availability
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
GET
Request headers
X-LIVEAGENT-API-VERSION
Request parameters
None
Query parameters
org_id
The ID of the Salesforce organization that’s associated with the Live Agent deployment.
deployment_id
The 15-digit ID of the Chat deployment that the chat request was initiated from.
26
Chat REST API Resources Breadcrumb
Availability.ids
An array of object IDs for which to verify availability.
Availability.needEstimatedWaitTime
Indicates whether the estimatedWaitTime property should be filled. Specify a value of 1 to request the estimated wait
time.
Request body
None
Response body
Availability response
Breadcrumb
Sets a breadcrumb value to the URL of the Web page that the chat visitor is viewing as the visitor chats with an agent. The agent can
then see the value of the breadcrumb to determine the page the chat visitor is viewing.
Syntax
URI
https://hostname/chat/rest/Visitor/Breadcrumb
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
Request parameters
None
Query parameters
None
Request body
Breadcrumb request
Response body
None
VisitorId
Generates a unique ID to track a chat visitor when they initiate a chat request and tracks the visitor’s activities as the visitor navigates
from one Web page to another.
27
Chat REST API Resources SensitiveDataRuleTriggered for Agents
Syntax
URI
https://hostname/chat/rest/Visitor/VisitorId
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
GET
Request headers
X-LIVEAGENT-API-VERSION
Request parameters
None
Query parameters
org_id
The Salesforce organization ID
deployment_id
The ID of the Chat deployment that the chat request was initiated from
Request body
None
Response body
VisitorId response
Syntax
URI
https://hostname/chat/rest/Agent/SensitiveDataRuleTriggered
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
Request parameters
None
28
Chat REST API Resources SensitiveDataRuleTriggered for Chasitors
Query parameters
None
Request body
SensitiveDataRuleTriggered for Agents request
Response body
None
Syntax
URI
https://hostname/chat/rest/Chasitor/SensitiveDataRuleTriggered
Available since release
This resource is available in API versions 29.0 and later.
Formats
JSON
HTTP methods
POST
Request headers
X-LIVEAGENT-API-VERSION
Request parameters
None
Query parameters
None
Request body
SensitiveDataRuleTriggered for Chasitors request
Response body
None
SEE ALSO:
Salesforce Help: Block Sensitive Data in Chats
29
CHAPTER 7 Request Bodies for Chat REST API
To perform a POST or GET request, pass query parameters or create a request body that’s formatted in JSON. Request bodies can contain
one or more other request bodies that are nested inside. Each request body can contain unique request properties.
Note: The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During
this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service
interruptions to your customers, migrate to Messaging for In-App and Web. Messaging offers many of the chat features that you
love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.
Breadcrumb
Request properties
Request body
"location":{
"type":"string",
"description":"The current location or URL of the visitor",
"required":true,
"version":29.0
}
ChasitorInit
Request properties
30
Request Bodies for Chat REST API
prechatEntities Array of Entity objects The records created, searched for, or 29.0
both depending on what
EntityFieldsMaps on page 55 has
enabled.
31
Request Bodies for Chat REST API
Request body
{
organizationId: "00DD0000000JVXs",
deploymentId: "572D000000000J6",
buttonId: "573D000000000OC",
agentId: "005B0000000F3b2",
doFallback: true,
sessionId: "5503f854-0203-4324-8ed5-f793a367426f",
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36",
language: "en-US",
screenResolution: "2560x1440",
visitorName: "Jon A.",
prechatDetails: [
{
label: "E-mail Address",
value: "[email protected]",
entityFieldMaps: [
{
entityName: "Contact",
fieldName: "Email",
isFastFillable: false,
isAutoQueryable: true,
isExactMatchable: true
}
],
transcriptFields: [
"c__EmailAddress"
],
displayToAgent: true
}
],
prechatEntities: [],
buttonOverrides: [
"573D000000000OD"
],
receiveQueueUpdates: true,
isPost: true
}
32
Request Bodies for Chat REST API
ChasitorResyncState
Request properties
Request body
{
organizationId: "00DD0000000JVXs"
}
ChasitorSneakPeek
Request properties
text String The text that the chat visitor is typing in the text input 29.0
area of the chat window.
Request body
{
position: 3,
text: "Hi there."
}
ChatMessage
Request properties
Request body
{
text: "I have a question about my account."
}
33
Request Bodies for Chat REST API
CustomEvent
Request properties
data String Data that’s relevant to the event that was sent to the agent. 29.0
Request body
{
type: "PromptForCreditCard",
data: "Visa"
}
MultiNoun
Request properties
Request body
{
nouns: [
{
prefix: "Chasitor",
noun: "ChatMessage",
object: {
text: "Goodbye"
}
},
{
prefix: "Chasitor",
noun: "ChatEnd",
object: {}
}
]
}
34
Request Bodies for Chat REST API
Request body
{
"rules": [
{
"name": "Replace-Bad-Word"
},
{
"name": "Filter-Out-Digits"
}
],
"chatId": "1a240b1a-f60e-456d-9f77-41cbfa7b9159"
}
Request body
{
"rules": [
{
"id": "0GORM00000001dM",
"name": "Replace-Bad-Word"
},
{
"id": "0GORM00000001dW",
"name": "Filter-Out-Digits"
}
]
}
35
CHAPTER 8 Response Bodies for Chat REST API
A request to a Chat REST API resource returns a response code. The successful execution of a resource request can also return a response
body in JSON format.
Note: The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During
this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service
interruptions to your customers, migrate to Messaging for In-App and Web. Messaging offers many of the chat features that you
love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.
Availability
Response Properties
Response body
{
"results":{
"type":"array",
"description":"List of valid patterns of IDs and their availability.",
"items":{
"name":"result",
"type":"object",
"properties":{
"id":{
"type":"string",
"description":"ID of the entity.",
"required":true,
"version":29.0
},
"isAvailable":{
"type":"boolean",
"description":"Whether or not the entity is available for chat.",
"version":29.0
}
}
},
"required":true,
36
Response Bodies for Chat REST API
"version":29.0
}
}
ChasitorSessionData
Response Properties
Response body
{
queuePosition: 1,
geoLocation: {
countryCode: "US",
countryName: "United States of America",
region: "CA",
city: "San Francisco",
organization: Salesforce,
latitude: 37.793880,
longitude: -122.395114
},
url: "http://yoursite",
oref: "http://www.google.com?q=yoursite",
postChatUrl: "http://yoursite/postchat",
sneakPeekEnabled: true,
37
Response Bodies for Chat REST API
chatMessages: [
{
type: "Agent",
name: "Andy L.",
content: "Hello, how can I help you?",
timestamp: 1376596367548,
sequence: 1
},
{
type: "Chasitor",
name: "Jon A.",
content: "I have a question for you.",
timestamp: 1376596349132
sequence: 2
}
]
}
ChasitorIdleTimeoutWarningEvent
Response properties
ChatEndReason
Response properties
38
Response Bodies for Chat REST API
ChatEstablished
Response properties
Response body
{
name: "Andy L.",
userId: "f1dda237-57f8-4816-b8e8-59775f1e44c8",
sneakPeekEnabled: true
}
ChatMessage
Response properties
39
Response Bodies for Chat REST API
Response body
{
name: "Andy L."
text: "Hello, how can I help you?"
}
ChatRequestFail
Response properties
Response body
{
reason: "Unavailable",
postChatUrl: "http://yoursite/postChat"
}
ChatRequestSuccess
Response properties
40
Response Bodies for Chat REST API
Response body
"{
queuePosition: 1,
estimatedWaitTime: 120,
geoLocation: {
countryCode:"US",
countryName: "United States of America",
region: "CA",
city: "San Francisco",
organization: Salesforce,
latitude: 37.793880,
longitude: -122.395114
},
url: "http://yoursite",
oref: "http://www.google.com?q=yoursite",
postChatUrl: "http://yoursite/postchat",
customDetails: [
{
label: "E-mail Address",
value: "[email protected]",
transcriptFields: [
"c__EmailAddress"
],
displayToAgent: true
}
],
visitorId: "acd47048-bd80-476e-aa33-741bd5cb05d3"
}"
41
Response Bodies for Chat REST API
ChatTransferred
Response properties
Response body
{
name: "Ryan S.",
userId: "edacfa56-b203-43d5-9e1b-678278b61263",
sneakPeekEnabled: false
}
CustomEvent
Response properties
Response body
{
type: "CreditCardEntered",
data: "5105105105105100"
}
42
Response Bodies for Chat REST API
Messages
Response Properties
Response body
{
messages: [
{
type: "ChatEstablished",
message: {
name: "Andy L.",
userId: "f1dda237-57f8-4816-b8e8-59775f1e44c8",
sneakPeekEnabled: true
}
}
],
sequence: 1,
offset: 1234567890
}
NewVisitorBreadcrumb
Response properties
43
Response Bodies for Chat REST API
Response body
{
location: "http://yoursite/page2"
}
QueueUpdate
Response properties
Response body
{
position: 3,
estimatedWaitTime: 120
}
ReconnectSession
Response properties
Response body
{
resetSequence: true,
affinityToken: "73061fa0"
}
44
Response Bodies for Chat REST API
SensitiveDataRules
Response Properties
Response body
{
"sensitiveDataRules": [
{
"name": "Replace-Bad-Word",
"pattern": "bad",
"id": "0GORM00000001dM",
"replacement": "bad word",
"actionType": "Replace"
},
{
"name": "Filter-Out-Digits",
"pattern": "[0-9]+",
"id": "0GORM00000001dW",
"replacement": "<DIGIT>",
"actionType": "Replace"
}
]
}
SessionId
Response Properties
45
Response Bodies for Chat REST API
Response body
{
id: "241590f5-2e59-44b5-af89-9cae83bb6947",
key:
"f6c1d699-84c7-473f-b194-abf4bf7cccf8!b65b13c7-f597-4dd2-aa3a-cbe01e69f19c",
affinityToken: "73061fa0"
clientPollTimeout: "30"
}
Settings
Response Properties
buttons Array of button objects A list of chat buttons, along with 29.0
their settings information, that
were specified when you made
the Settings request.
Response body
{
"pingRate":{
"type":"number",
"description":"The rate at which the visitor should ping the server to
maintain presence",
"required":true,
"version":29.0
},
"contentServerUrl":{
"type":"string",
"description":"The content server URL",
"required":true,
"version":29.0
},
"buttons":{
"type":"array",
"description":"The list of buttons",
"items":{
"name":"button",
"type":"object",
"properties":{
"id":{
"type":"string",
46
Response Bodies for Chat REST API
"version":29.0
},
/* Invite related settings */
"inviteImageUrl":{
"type":"string",
"description":"The image of the button",
"required":false,
"version":29.0
},
"inviteImageWidth":{
"type":"number",
"description":"The width of the button image",
"required":false,
"version":29.0
},
"inviteImageHeight":{
"type":"number",
"description":"The height of the button image",
"required":false,
"version":29.0
},
47
Response Bodies for Chat REST API
"inviteRenderer":{
"type":"string",
"description":"The animation option of the invite",
"required":false,
"version":29.0,
"enum":["Slide","Fade","Appear","Custom"]
},
"inviteStartPosition":{
"type":"string",
"description":"The start position of the animation",
"required":false,
"version":29.0,
"enum":["TopLeft","TopLeftTop","Top","TopRightTop","TopRight",
"TopRightRight","Right","BottomRightRight","BottomRight",
"BottomRightBottom","Bottom","BottomLeftBottom","BottomLeft",
"BottomLeftLeft","Left","TopLeftLeft"]
},
"inviteEndPosition":{
"type":"string",
"description":"The end position of the animation",
"required":false,
"version":29.0,
"enum":["TopLeft","Top","TopRight","Left","Center","Right","BottomLeft","Bottom","BottomRight"]
},
"hasInviteAfterAccept":{
"type":"boolean",
"description":"Whether or not invite will trigger after accepting",
"required":false,
"version":29.0
},
"hasInviteAfterReject":{
"type":"boolean",
"description":"Whether or not invite will trigger after rejecting",
"required":false,
"version":29.0
},
"inviteRejectTime":{
"type":"number",
"description":"The auto reject setting of the invite",
"required":false,
"version":29.0
},
"inviteRules":{
"type":"object",
"description":"The rules of the invite",
"required":false,
"version":29.0
}
48
Response Bodies for Chat REST API
SwitchServer
This response is returned for requests to Visitor resources if the Live Agent instance URL is not correct for the Organization ID provided.
Response Properties
Response body
{
"messages": [
"type": "SwitchServer"
"message": {
"newUrl": "https://LiveAgentPool.salesforceliveagent.com/chat"
}
]
}
VisitorId
Response Properties
Response body
"sessionId":{
"type":"string",
"description":"The session id of the visitor",
"required":true,
49
Response Bodies for Chat REST API
"version":29.0
}
SEE ALSO:
Status Codes and Error Responses
50
CHAPTER 9 Chat REST API Data Types
A request to a Chat REST API resource returns a response code. The successful execution of a resource request can also return a response
body in JSON format. Some response bodies return data types that contain their own properties. All property values that refer to a name
of an entity or field are case-sensitive.
Button
Properties
51
Chat REST API Data Types
52
Chat REST API Data Types
53
Chat REST API Data Types
CustomDetail
Properties
Entity
Properties
54
Chat REST API Data Types
EntityFieldsMaps
Properties
55
Chat REST API Data Types
GeoLocation
Properties
Message
Properties
56
Chat REST API Data Types
NounWrapper
Properties
Result
Properties
estimatedWaitTime number The estimated wait time for the FALSE 47.0
button in seconds. If the server
cannot retrieve the wait time, this
property returns -1.
Rule
Properties
57
Chat REST API Data Types
name String The name of the sensitive data rules TRUE 29.0
applied to the chat session. This
property applies to both agent and
chasitor.
SensitiveDataRule
Properties
pattern String The pattern of the sensitive data rule TRUE 29.0
pattern definition.
actionType String The action type if the message matches FALSE 29.0
the pattern.
TranscriptEntry
Properties
name String The name of the person who sent TRUE 29.0
the chat message.
58
Chat REST API Data Types
timestamp number The date and time when the TRUE 29.0
message was sent.
SEE ALSO:
Status Codes and Error Responses
Salesforce Help: Block Sensitive Data in Chats
59
CHAPTER 10 Status Codes and Error Responses
Each request returns a status code or error response to indicate whether the request was successful.
When an error occurs or when a response is successful, the response header contains an HTTP code, and the response body usually
contains:
• The HTTP response code
• The message accompanying the HTTP response code
204 “No Content” success code for Message request; resend the request as part of the message loop.
400 The request couldn’t be understood, usually because the JSON body contains an error.
403 The request has been refused because the session isn’t valid.
404 The requested resource couldn’t be found. Check the URI for errors.
405 The method specified in the Request-Line isn’t allowed for the resource specified in the URI.
409 A duplicate long poll using the same session ID has caused the chat to terminate. Reestablish the chat in a
new session.
500 An error has occurred within the Chat server, so the request couldn’t be completed. Contact Customer Support.
503 The affinity token has changed. Make a ReconnectSession request to get a new affinity token, then
make a ChasitorSessionData request to reestablish the chat visitor’s data within the new session.
SEE ALSO:
Your Message Long Polling Loop
ReconnectSession
ChasitorSessionData
Response Bodies for Chat REST API
Chat REST API Data Types
ReconnectSession
ChasitorSessionData
60
INDEX
Resources
A AgentDisconnect 20
AgentDisconnect 20
AgentNotTyping 20
AgentNotTyping 20
AgentTyping 21
AgentTyping 21
Availability 26
Availability 26
Breadcrumb 27
ChasitorNotTyping 13
B ChasitorResyncState 12
Breadcrumb 27 ChasitorSessionData 21
ChasitorSneakPeek 14
C ChasitorTyping 15
ChasitorNotTyping 13 ChatEnd 15
ChasitorResyncState 12 ChatEnded 21
ChasitorSessionData 21 ChatEstablished 22
ChasitorSneakPeek 14 ChatMessage 16, 22
ChasitorTyping 15 ChatRequestFail 22
ChatEnd 15 ChatRequestSuccess 22
ChatEnded 21 ChatTransferred 23
ChatEstablished 22 CustomEvent 17, 23
ChatMessage 16, 22 Data Types 51
ChatRequestFail 22 Long Polling 6
ChatRequestSuccess 22 Messages 17–18
ChatTransferred 23 MultiNoun 24
CustomEvent 17, 23 NewVisitorBreadcrumb 23
QueueUpdate 23
D Request headers 5
Data Types 51 Requests 8–9, 13, 25, 30
SensitiveDataRules 24
E SensitiveDataRuleTriggered 28–29
Error responses 60 SessionId 8
Settings 25
M VisitorId 27
Messages 17 Responses
MultiNoun 24 Data Types 51
N S
NewVisitorBreadcrumb 23 SensitiveDataRules 24
SensitiveDataRuleTriggered 28–29
Q SessionId 8
QueueUpdate 23 Settings 25
Status codes 60
R
Requests V
Headers 5 VisitorId 27
61