Agents
You can use the API to get or set agent information.
If you created your Zendesk Chat account in Zendesk Support, access to the Chat Accounts and Agents APIs is restricted to GET requests. You can still use the other Chat APIs normally.JSON format
Agents are represented as JSON objects with the following properties:
| Name | Type | Read-only | Mandatory | Description |
|---|---|---|---|---|
| create_date | string | true | false | The date of creation of the agent |
| departments | array | true | false | The departments for the agent |
| display_name | string | false | false | The name to be displayed for the agent |
| string | false | false | The email address of the agent | |
| enabled | integer | false | false | Describes whether the agent is enabled |
| enabled_departments | array | true | false | The enabled departments for the agent |
| first_name | string | false | false | The agent's first name |
| id | integer | true | false | The ID of the agent |
| last_name | string | false | false | The agent's last name |
| role_id | integer | false | false | The role ID of the agent |
| roles | object | true | false | Special role privileges. See below for values (deprecated) |
| skills | array | true | false | The skills for the agent |
The roles attribute has the following values:
| Value | Users |
|---|---|
| owner | owner of the account |
| administrator | agent with administrator privileges |
Note: The following field is required during creation:
| Name | Type | Read-only | Description |
|---|---|---|---|
| password | string | yes | This is the password for the agent. This is only required during creation. |
Example
{"create_date": "2014-09-30T08:25:09Z","departments": [],"display_name": "Johnny","email": "[email protected]","enabled": 1,"enabled_departments": [],"first_name": "John","id": 5,"last_name": "Doe","role_id": 3,"roles": {"administrator": false,"owner": false}}
List Agents
GET /api/v2/chat/agents
Lists all the agents for your account.
Pagination
This endpoint uses cursor-based pagination. The records are ordered sequentially by record id. The endpoint takes max_id and since_id query parameters, which act as separate cursors that track the record ids in the recordset. The max_id cursor moves backward through the recordset, with the record ids getting smaller. The since_id cursor moves forward, with the record ids getting larger.
-
Use the
max_idparameter to paginate backward through the recordset. Example: "Get the previous 200 records, ending with and including themax_idrecord.""https://{subdomain}.zendesk.com/api/v2/chat/agents?max_id=10&limit=200" -
Use the
since_idparameter to paginate forward through the recordset. Example: "Get the next 200 records, starting with and including thesince_idrecord.""https://{subdomain}.zendesk.com/api/v2/chat/agents?since_id=10&limit=200"
The next page can be retrieved by computing the next since_id by adding 1 to the ID of the last record in the current set, and specifying that as the since_id in the next request. Similarly, the previous page can be retrieved by making a request that species a max_id that is 1 less than the first element of the current record set.
Additionally, the next page and the previous page paths will be available as headers in the response.
If any of the pagination parameters (since_id, max_id, limit) are present, the default number of results is 10, but you can change it with the limit parameter. If none of the pagination parameters are present, the entire record set is returned.
Zendesk Chat recommends using pagination wherever possible. Non-paginated queries will be deprecated in subsequent releases of the API.
Allowed for
- Agent
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| limit | integer | Query | false | Number of records that will be returned by the endpoint. Default to 10. |
| max_id | integer | Query | false | Use the max_id parameter to paginate backward through the recordset |
| since_id | integer | Query | false | Use the since_id parameter to paginate forward through the recordset |
Code Samples
curl
curl "https://{subdomain}.zendesk.com/api/v2/chat/agents?since_id=5&limit=2" \-v -H "Authorization: Bearer {token}"
Go
import ("fmt""io""net/http")func main() {url := "https://subdomain.zendesk.com/api/v2/chat/agents?limit=20&max_id=20&since_id=10"method := "GET"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/agents").newBuilder().addQueryParameter("limit", "20").addQueryParameter("max_id", "20").addQueryParameter("since_id", "10");Request request = new Request.Builder().url(urlBuilder.build()).method("GET", null).addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'GET',url: 'https://subdomain.zendesk.com/api/v2/chat/agents',headers: {'Content-Type': 'application/json',},params: {'limit': '20','max_id': '20','since_id': '10',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsurl = "https://subdomain.zendesk.com/api/v2/chat/agents?limit=20&max_id=20&since_id=10"headers = {"Content-Type": "application/json",}response = requests.request("GET",url,headers=headers)print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/agents")uri.query = URI.encode_www_form("limit": "20", "max_id": "20", "since_id": "10")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK[{"create_date": "2014-09-30T08:25:09Z","departments": [],"display_name": "Johnny","email": "[email protected]","enabled": 1,"first_name": "John","id": 5,"last_name": "Doe","role_id": 3,"roles": {"administrator": false,"owner": false}}]
Show Agent by ID
GET /api/v2/chat/agents/{agent_id}
Fetches an agent by his or her ID.
Allowed for
- Administrator
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| agent_id | integer | Path | true | The ID of the agent |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/chat/agents/{agent_id} \-v -H "Authorization: Bearer {token}"
Go
import ("fmt""io""net/http")func main() {url := "https://subdomain.zendesk.com/api/v2/chat/agents/1"method := "GET"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/agents/1").newBuilder();Request request = new Request.Builder().url(urlBuilder.build()).method("GET", null).addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'GET',url: 'https://subdomain.zendesk.com/api/v2/chat/agents/1',headers: {'Content-Type': 'application/json',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsurl = "https://subdomain.zendesk.com/api/v2/chat/agents/1"headers = {"Content-Type": "application/json",}response = requests.request("GET",url,headers=headers)print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/agents/1")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"create_date": "2014-09-30T08:25:09Z","departments": [],"display_name": "Johnny","email": "[email protected]","enabled": 1,"enabled_departments": [],"first_name": "John","id": 5,"last_name": "Doe","role_id": 3,"roles": {"administrator": false,"owner": false}}
Show Agent by Email
GET /api/v2/chat/agents/email/{email}
Fetches an agent using the agent's email address.
Allowed for
- Administrator
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| string | Path | true | The email of the agent |
Code Samples
curl
curl "https://{subdomain}.zendesk.com/api/v2/chat/agents/email/{email_id}" \-v -H "Authorization: Bearer {token}"
Go
import ("fmt""io""net/http")func main() {url := "https://subdomain.zendesk.com/api/v2/chat/agents/email/[email protected]"method := "GET"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/agents/email/[email protected]").newBuilder();Request request = new Request.Builder().url(urlBuilder.build()).method("GET", null).addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'GET',url: 'https://subdomain.zendesk.com/api/v2/chat/agents/email/[email protected]',headers: {'Content-Type': 'application/json',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsurl = "https://subdomain.zendesk.com/api/v2/chat/agents/email/[email protected]"headers = {"Content-Type": "application/json",}response = requests.request("GET",url,headers=headers)print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/agents/email/[email protected]")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"create_date": "2014-09-30T08:25:09Z","departments": [],"display_name": "Johnny","email": "[email protected]","enabled": 1,"enabled_departments": [],"first_name": "John","id": 5,"last_name": "Doe","role_id": 3,"roles": {"administrator": false,"owner": false}}
Show Requesting Agent
GET /api/v2/chat/agents/me
Fetches your data.
Allowed for
- Agent
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/chat/agents/me \-v -H "Authorization: Bearer {token}"
Go
import ("fmt""io""net/http")func main() {url := "https://subdomain.zendesk.com/api/v2/chat/agents/me"method := "GET"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/agents/me").newBuilder();Request request = new Request.Builder().url(urlBuilder.build()).method("GET", null).addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'GET',url: 'https://subdomain.zendesk.com/api/v2/chat/agents/me',headers: {'Content-Type': 'application/json',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsurl = "https://subdomain.zendesk.com/api/v2/chat/agents/me"headers = {"Content-Type": "application/json",}response = requests.request("GET",url,headers=headers)print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/agents/me")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"create_date": "2014-09-30T08:25:09Z","departments": [],"display_name": "Johnny","email": "[email protected]","enabled": 1,"enabled_departments": [],"first_name": "John","id": 5,"last_name": "Doe","role_id": 3,"roles": {"administrator": false,"owner": false}}
Create Agent
POST /api/v2/chat/agents
Creates an agent in an account.
Note: An additional field, password, needs to be provided during creation.
Allowed for
- Administrator
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/chat/agents \-d '{"email": "[email protected]","password": "secretpassword","first_name": "John","last_name": "Smith","display_name": "Smith","enabled": 1}' \-v -H "Authorization: Bearer {token}" \-H "Content-Type: application/json" -X POST
Go
import ("fmt""io""net/http")func main() {url := "https://subdomain.zendesk.com/api/v2/chat/agents"method := "POST"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/agents").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""""");Request request = new Request.Builder().url(urlBuilder.build()).method("POST", body).addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'POST',url: 'https://subdomain.zendesk.com/api/v2/chat/agents',headers: {'Content-Type': 'application/json',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsurl = "https://subdomain.zendesk.com/api/v2/chat/agents"headers = {"Content-Type": "application/json",}response = requests.request("POST",url,headers=headers)print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/agents")request = Net::HTTP::Post.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
201 Created
// Status 201 Created{"display_name": "Smith","email": "[email protected]","enabled": 1,"first_name": "John","last_name": "Smith"}
Update Agent
PUT /api/v2/chat/agents/{agent_id}
Updates details of an agent.
Allowed for
- Administrator
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| agent_id | integer | Path | true | The ID of the agent |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/chat/agents/{agent_id} \-d '{"first_name": "John", "last_name": "Smith", "role_id": 2}' \-v -H "Authorization: Bearer {token}" \-H "Content-Type: application/json" -X PUT
Go
import ("fmt""io""net/http")func main() {url := "https://subdomain.zendesk.com/api/v2/chat/agents/1"method := "PUT"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/agents/1").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""""");Request request = new Request.Builder().url(urlBuilder.build()).method("PUT", body).addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'PUT',url: 'https://subdomain.zendesk.com/api/v2/chat/agents/1',headers: {'Content-Type': 'application/json',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsurl = "https://subdomain.zendesk.com/api/v2/chat/agents/1"headers = {"Content-Type": "application/json",}response = requests.request("PUT",url,headers=headers)print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/agents/1")request = Net::HTTP::Put.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"display_name": "Smith","email": "[email protected]","enabled": 1,"first_name": "John","last_name": "Smith"}
Update Requesting Agent
PUT /api/v2/chat/agents/me
Updates your data.
Allowed for
- Administrator
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/chat/agents/me \-d '{"first_name" : "Jonathan"}' \-v -H "Authorization: Bearer {token}" \-H "Content-Type: application/json" -X PUT
Go
import ("fmt""io""net/http")func main() {url := "https://subdomain.zendesk.com/api/v2/chat/agents/me"method := "PUT"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/agents/me").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""""");Request request = new Request.Builder().url(urlBuilder.build()).method("PUT", body).addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'PUT',url: 'https://subdomain.zendesk.com/api/v2/chat/agents/me',headers: {'Content-Type': 'application/json',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsurl = "https://subdomain.zendesk.com/api/v2/chat/agents/me"headers = {"Content-Type": "application/json",}response = requests.request("PUT",url,headers=headers)print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/agents/me")request = Net::HTTP::Put.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"display_name": "Smith","email": "[email protected]","enabled": 1,"first_name": "John","last_name": "Smith"}
Delete Agent
DELETE /api/v2/chat/agents/{agent_id}
Deletes an agent from an account.
Allowed for
- Administrator
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| agent_id | integer | Path | true | The ID of the agent |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/chat/agents/{agent_id} \-v -H "Authorization: Bearer {token}" -X DELETE
Go
import ("fmt""io""net/http")func main() {url := "https://subdomain.zendesk.com/api/v2/chat/agents/1"method := "DELETE"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/agents/1").newBuilder();Request request = new Request.Builder().url(urlBuilder.build()).method("DELETE", null).addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'DELETE',url: 'https://subdomain.zendesk.com/api/v2/chat/agents/1',headers: {'Content-Type': 'application/json',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsurl = "https://subdomain.zendesk.com/api/v2/chat/agents/1"headers = {"Content-Type": "application/json",}response = requests.request("DELETE",url,headers=headers)print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/agents/1")request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
204 No Content
// Status 204 No Contentnull
Delete Shortcuts By Agent ID
DELETE /api/v2/chat/agents/{agent_id}/shortcuts
Deletes an agent's shortcuts by their ID.
Warning: Deleted shortcuts are not recoverable.
Allowed for
- Administrator
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| agent_id | integer | Path | true | The ID of the agent |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/chat/agents/{agent_id}/shortcuts \-v -H "Authorization: Bearer {token}" -X DELETE
Go
import ("fmt""io""net/http")func main() {url := "https://subdomain.zendesk.com/api/v2/chat/agents/1/shortcuts"method := "DELETE"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/agents/1/shortcuts").newBuilder();Request request = new Request.Builder().url(urlBuilder.build()).method("DELETE", null).addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'DELETE',url: 'https://subdomain.zendesk.com/api/v2/chat/agents/1/shortcuts',headers: {'Content-Type': 'application/json',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsurl = "https://subdomain.zendesk.com/api/v2/chat/agents/1/shortcuts"headers = {"Content-Type": "application/json",}response = requests.request("DELETE",url,headers=headers)print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/agents/1/shortcuts")request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
204 No Content
// Status 204 No Contentnull