Is it possible to have an api call to check whether chat button is online or offline ? We know that we can have chat button code which will show online or offline status. But instead of that, Is it possible to make it centralized by calling an api to salesforce to check whether agents are available or not?

  • remember to accept the answer if it proved useful, you have several posts with asnwers that have not been accepted. thanks
    – glls
    Oct 15, 2018 at 19:34

1 Answer 1


Yes, you can do that. You must need to make an API call your live agent endpoint with providing button Id, org id and deployment id.

Here is the help doc: https://developer.salesforce.com/docs/atlas.en-us.live_agent_rest.meta/live_agent_rest/live_agent_rest_Availability.htm

Here is the working sample:

String endpoint = 'https://d.la1-c1cs-phx.salesforceliveagent.com/chat/rest/Visitor/Availability?Availability.prefix=Visitor&Availability.ids=57xxB00000000Wq&deployment_id=57xxB00000000pn&org_id=00Dxxx000000Hhli';
HttpRequest createReq = new HttpRequest();
createReq.setHeader('X-LIVEAGENT-API-VERSION', '40');
createReq.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());//not required..just as best practice
createReq.setHeader('Content-Type', 'application/json');
Http h = new Http();   
HttpResponse createRes = h.send(createReq);   

Where Availability.ids = List of chat button ids; deployment_id = Live agent Deployment Id; org_id = Salesforce Internal org id.

Also, please note that given example is for Apex. Similarly you can make REST http call from any other type of language/platform to know the availability and you do not need to pass any access token/auth token...

enter image description here

  • I didn't get which user info are you using to have authentication? Currently we have hosted live chat button on a website and i don't thing we can use guest users session id here. Can you elaborate more on authentication mechanism used here? May 23, 2018 at 13:03
  • @ChaithraKN ...this is just an apex example...you dont need to pass access token simply make http request....I updated my answer!
    – Ayub
    May 23, 2018 at 18:52
  • Is it possible to query the availability of the chat button in apex instead of rest API? Jun 3, 2018 at 15:09
  • No you...can not for now. May be salesforce releases in it near future...but certainly you can use this code in apex as well for time being..
    – Ayub
    Jun 4, 2018 at 5:00
  • Yes, I agree we can use this in Apex, but i am concerned about no of API calls to salesforce. Jun 4, 2018 at 8:26

You must log in to answer this question.

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