I've recently tried using the Live Agent Rest API and I am unable to even establish a session. I'm following the official online documentation, and according to it when I do the initial SessionId call, I'm suppose to receive 4 parameters:

id: "241590f5-2e59-44b5-af89-9cae83bb6947",
key: "f6c1d699-84c7-473f-b194-abf4bf7cccf8!b65b13c7-f597-4dd2-aa3a-cbe01e69f19c",
affinityToken: "73061fa0",
clientPollTimeout: "30"

Unfortunately, what I get when I do the call (both to DE org and sandbox) is this:

id: "f6c1d699-84c7-473f-b194-abf4bf7cccf8",
key: "f6c1d699-84c7-473f-b194-abf4bf7cccf8!b65b13c7-f597-4dd2-aa3a-cbe01e69f19c",

As you can see the affinity token is missing, which is quite unfortunate as I need to send the session key AND the affinity token in the header of each subsequent call. Needless to say, if I don't put the token in I get an "invalid session" error.

Has anybody tried using the Live Agent Rest API? Are you having the same issue?


2 Answers 2


Received an answer from Salesforce support:

First of all, header parameter names listed in the documentation are wrong. They should be:

  • X-LIVEAGENT-API-VERSION (this is the only one correctly named in the docs)

To have the sessionId call return the affinity token, along with the X-LIVEAGENT-API-VERSION you also have to send the X-LIVEAGENT-AFFINITY parameter with the value explicitly stated as 'null'. This will return all the parameters except the session timeout, but for now that value is 30 second.

Also some other tips around establishing a session:

When using the chasitorInit call, completely disregard the example given in the docs - use only the properties mentioned in the table for this call. The example a) has a completely faulty JSON that will not pass any JSON validator; and b) uses extra properties that, when included, will result in a 400 error (bad request).

For now I'm working on the long polling - I'm sending messages requests but so far I'm only getting a 204 (no content) and no notification on the agent side.


Thank you for the answer. Looks like the documentation has been updated regarding the header parameters, but it still does not include the information that X-LIVEAGENT-AFFINITY should be explicitly set to "null" in order to receive the correct token in response.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .