Users
Zendesk Support has three types of users: end users (your customers), agents, and administrators.
End users
End users request support through tickets. End users have access to Help Center where they can view knowledge base articles and community content, access their ticket history, and submit new tickets.
Agents
Agents work in Zendesk Support to solve tickets. Agents can be divided into multiple groups and can also belong to multiple groups. Agents don't have access to administrative configuration in Zendesk Support such as business rules or automations, but can configure their own macros and views.
Administrators
Administrators have all the abilities of agents, plus administrative abilities. Accounts on the Enterprise plan and above can configure custom roles to give agents varying degrees of administrative access.
Listing Requested Tickets and CC'ed Tickets
Use the Tickets API to list:
Listing Help Center Content by a User
Use the Help Center API to list:
- articles and article comments created by a user
- community posts and post comments created by a user
JSON format
Users are represented as JSON objects with the following properties:
Name | Type | Read-only | Mandatory | Description |
---|---|---|---|---|
active | boolean | true | false | false if the user has been deleted |
alias | string | false | false | An alias displayed to end users |
chat_only | boolean | true | false | Whether or not the user is a chat-only agent |
created_at | string | true | false | The time the user was created |
custom_role_id | integer | false | false | A custom role if the user is an agent on the Enterprise plan or above |
default_group_id | integer | false | false | The id of the user's default group |
details | string | false | false | Any details you want to store about the user, such as an address |
string | false | false | The user's primary email address. *Writeable on create only. On update, a secondary email is added. See Email Address | |
external_id | string | false | false | A unique identifier from another system. The API treats the id as case insensitive. Example: "ian1" and "IAN1" are the same value. |
iana_time_zone | string | true | false | The time zone for the user |
id | integer | true | false | Automatically assigned when the user is created |
last_login_at | string | true | false | Last time the user signed in to Zendesk Support or made an API request using an API token or basic authentication |
locale | string | false | false | The user's locale. A BCP-47 compliant tag for the locale. If both "locale" and "locale_id" are present on create or update, "locale_id" is ignored and only "locale" is used. |
locale_id | integer | false | false | The user's language identifier |
moderator | boolean | false | false | Designates whether the user has forum moderation capabilities |
name | string | false | true | The user's name |
notes | string | false | false | Any notes you want to store about the user |
only_private_comments | boolean | false | false | true if the user can only create private comments |
organization_id | integer | false | false | The id of the user's organization. If the user has more than one organization memberships, the id of the user's default organization. If updating, see Organization ID |
phone | string | false | false | The user's primary phone number. See Phone Number below |
photo | object | false | false | The user's profile picture represented as an Attachment object |
remote_photo_url | string | false | false | A URL pointing to the user's profile picture. |
report_csv | boolean | true | false | This parameter is inert and has no effect. It may be deprecated in the future. Previously, this parameter determined whether a user could access a CSV report in a legacy Guide dashboard. This dashboard has been removed. See Announcing Guide legacy reporting upgrade to Explore |
restricted_agent | boolean | false | false | If the agent has any restrictions; false for admins and unrestricted agents, true for other agents |
role | string | false | false | The user's role. Possible values are "end-user", "agent", or "admin" |
role_type | integer | true | false | The user's role id. 0 for a custom agent, 1 for a light agent, 2 for a chat agent, 3 for a chat agent added to the Support account as a contributor (Chat Phase 4), 4 for an admin, and 5 for a billing admin |
shared | boolean | true | false | If the user is shared from a different Zendesk Support instance. Ticket sharing accounts only |
shared_agent | boolean | true | false | If the user is a shared agent from a different Zendesk Support instance. Ticket sharing accounts only |
shared_phone_number | boolean | false | false | Whether the phone number is shared or not. See Phone Number below |
signature | string | false | false | The user's signature. Only agents and admins can have signatures |
suspended | boolean | false | false | If the agent is suspended. Tickets from suspended users are also suspended, and these users cannot sign in to the end user portal |
tags | array | false | false | The user's tags. Only present if your account has user tagging enabled |
ticket_restriction | string | false | false | Specifies which tickets the user has access to. Possible values are: "organization", "groups", "assigned", "requested", null. "groups" and "assigned" are valid only for agents. If you pass an invalid value to an end user (for example, "groups"), they will be assigned to "requested", regardless of their previous access |
time_zone | string | false | false | The user's time zone. See Time Zone |
two_factor_auth_enabled | boolean | true | false | If two factor authentication is enabled |
updated_at | string | true | false | The time the user was last updated |
url | string | true | false | The user's API url |
user_fields | object | false | false | Values of custom fields in the user's profile. See User Fields |
verified | boolean | false | false | Any of the user's identities is verified. See User Identities |
Email Address
You can specify a user's primary email address when you create the user. See Specifying email and verified attributes.
To update a user's primary email address, use the Make Identity Primary endpoint.
Time Zone
A time_zone
name consists of a string such as "Eastern Time (US & Canada)". For a list of valid names, click https://support.zendesk.com/api/v2/time_zones. For details, see Time Zones.
Request body in User API:
{
"user": {
"id": 35436,
"name": "Johnny Agent",
"time_zone": "Berlin",
...
}
}
User Fields
You can use the user_fields
object to set the value of one or more custom fields in the user's profile.
Specify field keys as the properties to set. Example:
"user_fields": {
"membership_level": "silver",
"membership_expires": "2019-07-23T00:00:00Z"
}
For more information, see User Fields and Adding custom fields to users.
Phone Number
The phone number should comply with the E.164 international telephone numbering plan. Example +15551234567
.
E164 numbers are international numbers with a country dial prefix, usually an area code and a subscriber number.
A valid E.164 phone number must include a country calling code.
A phone number can be one of the following types:
- A direct line linked to a single user, which is indicated by a
shared_phone_number
attribute of false. A direct line can be used as a user identity - A shared number linked to multiple users, indicated by a
shared_phone_number
attribute of true. A shared number can not be used as a user identity
See Understanding how phone numbers are linked to end-user profiles in the Support Help Center.
Organization ID
The organization_id
property returns the id of the user's organization. If the user has more than one organization memberships, the id of the user's default organization is returned.
The field is writable. However, if you make a request to update the organization_id
property, the organization_id
of the request updates the default organization for that user and removes all other organizations currently associated with that user. Zendesk recommends using the Organization Memberships API to add or delete organizations for a user.
JSON Format for End Users
When an end user makes the request, the user is returned with the following attributes:
Name | Type | Read-only | Mandatory | Comment |
---|---|---|---|---|
id | integer | yes | no | Automatically assigned when creating users |
string | no | no | The primary email address of this user. If the primary email address is not verified, the secondary email address is used | |
name | string | no | yes | The name of the user |
created_at | date | yes | no | The time the user was created |
locale | string | yes | no | The locale for this user |
locale_id | integer | no | no | The language identifier for this user |
organization_id | integer | no | no | The id of the user's organization. If the user has more than one organization memberships, the id of the user's default organization. If updating, see Organization ID |
phone | string | no | no | The primary phone number of this user. See Phone Number in the Users API |
shared_phone_number | boolean | yes | no | Whether the phone number is shared or not. See Phone Number in the Users API |
photo | Attachment | no | no | The user's profile picture represented as an Attachment object |
role | string | no | no | The role of the user. Possible values: "end-user", "agent", "admin" |
time_zone | string | no | no | The time-zone of this user |
updated_at | date | yes | no | The time of the last update of the user |
url | string | yes | no | The API url of this user |
verified | boolean | no | no | Any of the user's identities is verified. See User Identities |
Responses will vary depending on the role of the client making the request. The following example is a response for an end-user role.
Example
{
"id": 35436,
"url": "https://company.zendesk.com/api/v2/end_users/35436.json",
"name": "Johnny End User",
"created_at": "2009-07-20T22:55:29Z",
"updated_at": "2011-05-05T10:38:52Z",
"time_zone": "Copenhagen",
"email": "[email protected]",
"phone": "+15551234567",
"locale": "en-US",
"locale_id": 1,
"organization_id": 57542,
"role": "end-user",
"verified": true,
"photo": {
"id": 928374,
"name": "my_funny_profile_pic.png",
"content_url": "https://company.zendesk.com/photos/my_funny_profile_pic.png",
"content_type": "image/png",
"size": 166144,
"thumbnails": [
{
"id": 928375,
"name": "my_funny_profile_pic_thumb.png",
"content_url": "https://company.zendesk.com/photos/my_funny_profile_pic_thumb.png",
"content_type": "image/png",
"size": 58298
}
]
}
}
This example is a response for an admin or agent request.
Example
{
"active": true,
"alias": "Mr. Johnny",
"created_at": "2009-07-20T22:55:29Z",
"custom_role_id": 9373643,
"details": "",
"email": "[email protected]",
"external_id": "sai989sur98w9",
"iana_time_zone": "Pacific/Pago_Pago",
"id": 35436,
"last_login_at": "2011-05-05T10:38:52Z",
"locale": "en-US",
"locale_id": 1,
"moderator": true,
"name": "Johnny Agent",
"notes": "Johnny is a nice guy!",
"only_private_comments": false,
"organization_id": 57542,
"phone": "+15551234567",
"photo": {
"content_type": "image/png",
"content_url": "https://company.zendesk.com/photos/my_funny_profile_pic.png",
"id": 928374,
"name": "my_funny_profile_pic.png",
"size": 166144,
"thumbnails": [
{
"content_type": "image/png",
"content_url": "https://company.zendesk.com/photos/my_funny_profile_pic_thumb.png",
"id": 928375,
"name": "my_funny_profile_pic_thumb.png",
"size": 58298
}
]
},
"restricted_agent": true,
"role": "agent",
"role_type": 0,
"shared": false,
"shared_agent": false,
"signature": "Have a nice day, Johnny",
"suspended": true,
"tags": [
"enterprise",
"other_tag"
],
"ticket_restriction": "assigned",
"time_zone": "Copenhagen",
"updated_at": "2011-05-05T10:38:52Z",
"url": "https://company.zendesk.com/api/v2/users/35436.json",
"user_fields": {
"user_date": "2012-07-23T00:00:00Z",
"user_decimal": 5.1,
"user_dropdown": "option_1"
},
"verified": true
}
List Users
GET /api/v2/users
GET /api/v2/groups/{group_id}/users
GET /api/v2/organizations/{organization_id}/users
Pagination
- Cursor pagination (recommended)
- Offset pagination
See Pagination.
Returns a maximum of 100 records per page.
Allowed For
- Admins, Agents and Light Agents
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
external_id | string | Query | false | List users by external id. External id has to be unique for each user under the same account. |
permission_set | integer | Query | false | For custom roles which is available on the Enterprise plan and above. You can only filter by one role ID per request |
role | string | Query | false | Filters the results by role. Possible values are "end-user", "agent", or "admin". Allowed values are "end-user", "agent", or "admin". |
role[] | string | Query | false | Filters the results by more than one role using the format role[]={role}&role[]={role} |
Code Samples
cURL
# List Users
curl https://{subdomain}.zendesk.com/api/v2/users.json \
-v -u {email_address}/token:{api_token}
# with role filtering
# **Note**: If filtering by multiple roles in curl, make sure to include
# the `-g` flag to prevent curl from interpreting the square brackets
# as globbing characters. Also enclose the URL in quotes. Example:
curl -g 'https://{subdomain}.zendesk.com/api/v2/users.json?role[]=admin&role[]=end-user' \
-v -u {email_address}/token:{api_token}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://example.zendesk.com/api/v2/users?external_id=abc&permission_set=123&role=agent&role[]=agent"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"
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://example.zendesk.com/api/v2/users")
.newBuilder()
.addQueryParameter("external_id", "abc")
.addQueryParameter("permission_set", "123")
.addQueryParameter("role", "agent")
.addQueryParameter("role[]", "agent");
String userCredentials = "your_email_address" + "/token:" + "your_api_token";
String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", basicAuth)
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://example.zendesk.com/api/v2/users',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"
},
params: {
'external_id': 'abc',
'permission_set': '123',
'role': 'agent',
'role[]': 'agent',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
from requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/users?external_id=abc&permission_set=123&role=agent&role[]=agent"
headers = {
"Content-Type": "application/json",
}
email_address = 'your_email_address'
api_token = 'your_api_token'
# Use basic authentication
auth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(
"GET",
url,
auth=auth,
headers=headers
)
print(response.text)
Ruby
require "net/http"
require "base64"
uri = URI("https://example.zendesk.com/api/v2/users")
uri.query = URI.encode_www_form("external_id": "abc", "permission_set": "123", "role": "agent", "role[]": "agent")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
email = "your_email_address"
api_token = "your_api_token"
credentials = "#{email}/token:#{api_token}"
encoded_credentials = Base64.strict_encode64(credentials)
request["Authorization"] = "Basic #{encoded_credentials}"
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
{
"users": [
{
"id": 223443,
"name": "Johnny Agent"
},
{
"id": 8678530,
"name": "James A. Rosen"
}
]
}
Search Users
GET /api/v2/users/search
Returns an array of users who meet the search criteria.
Returns up to 100 records per page to a maximum of 10,000 records per query. See Using offset pagination.
Pagination
- Offset pagination only
Allowed For
- Agents
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
external_id | string | Query | false | The external_id parameter does not support the search syntax. It only accepts ids. |
query | string | Query | false | The query parameter supports the Zendesk search syntax for more advanced user searches. It can specify a partial or full value of any user property, including name, email address, notes, or phone. Example: query="jdoe" . See the Search API. |
Code Samples
cURL
curl https://{subdomain}.zendesk.com/api/v2/users/search.json?query=gil \
-v -u {email_address}/token:{api_token}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://example.zendesk.com/api/v2/users/search?external_id=abc124&query=jdoe"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"
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://example.zendesk.com/api/v2/users/search")
.newBuilder()
.addQueryParameter("external_id", "abc124")
.addQueryParameter("query", "jdoe");
String userCredentials = "your_email_address" + "/token:" + "your_api_token";
String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", basicAuth)
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://example.zendesk.com/api/v2/users/search',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"
},
params: {
'external_id': 'abc124',
'query': 'jdoe',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
from requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/users/search?external_id=abc124&query=jdoe"
headers = {
"Content-Type": "application/json",
}
email_address = 'your_email_address'
api_token = 'your_api_token'
# Use basic authentication
auth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(
"GET",
url,
auth=auth,
headers=headers
)
print(response.text)
Ruby
require "net/http"
require "base64"
uri = URI("https://example.zendesk.com/api/v2/users/search")
uri.query = URI.encode_www_form("external_id": "abc124", "query": "jdoe")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
email = "your_email_address"
api_token = "your_api_token"
credentials = "#{email}/token:#{api_token}"
encoded_credentials = Base64.strict_encode64(credentials)
request["Authorization"] = "Basic #{encoded_credentials}"
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
{
"users": [
{
"id": 35436,
"name": "Robert Jones",
"notes": "sigil issue"
},
{
"id": 9873843,
"name": "Terry Gilliam"
}
]
}
Autocomplete Users
GET /api/v2/users/autocomplete?name={name}
Returns an array of users whose name starts with the value specified in the name
parameter.
It only returns users with no foreign identities.
Allowed For
- Agents
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
field_id | string | Query | false | The id of a lookup relationship field. The type of field is determined by the source param |
name | string | Query | true | The name to search for the user. |
source | string | Query | false | If a field_id is provided, this specifies the type of the field. For example, if the field is on a "zen:user", it references a field on a user |
Code Samples
cURL
curl https://{subdomain}.zendesk.com/api/v2/users/autocomplete.json?name=gil \
-u {email_address}/token:{api_token}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://example.zendesk.com/api/v2/users/autocomplete?field_id=&name=gil&source="
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"
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://example.zendesk.com/api/v2/users/autocomplete")
.newBuilder()
.addQueryParameter("field_id", "")
.addQueryParameter("name", "gil")
.addQueryParameter("source", "");
String userCredentials = "your_email_address" + "/token:" + "your_api_token";
String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", basicAuth)
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://example.zendesk.com/api/v2/users/autocomplete',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"
},
params: {
'field_id': '',
'name': 'gil',
'source': '',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
from requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/users/autocomplete?field_id=&name=gil&source="
headers = {
"Content-Type": "application/json",
}
email_address = 'your_email_address'
api_token = 'your_api_token'
# Use basic authentication
auth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(
"GET",
url,
auth=auth,
headers=headers
)
print(response.text)
Ruby
require "net/http"
require "base64"
uri = URI("https://example.zendesk.com/api/v2/users/autocomplete")
uri.query = URI.encode_www_form("field_id": "", "name": "gil", "source": "")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
email = "your_email_address"
api_token = "your_api_token"
credentials = "#{email}/token:#{api_token}"
encoded_credentials = Base64.strict_encode64(credentials)
request["Authorization"] = "Basic #{encoded_credentials}"
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
{
"users": [
{
"id": 35436,
"name": "Robert Jones",
"notes": "sigil issue"
},
{
"id": 9873843,
"name": "Terry Gilliam"
}
]
}
Count Users
GET /api/v2/users/count
GET /api/v2/groups/{group_id}/users/count
GET /api/v2/organizations/{organization_id}/users/count
Returns an approximate count of users. If the count exceeds 100,000, it is updated every 24 hours.
The response includes a refreshed_at
property in a count
object that contains a timestamp indicating when the count was last updated.
Note: When the count exceeds 100,000, the refreshed_at
property may occasionally be null.
This indicates that the count is being updated in the background. The count
object's value
property is limited to 100,000 until the update is complete.
Allowed For
- Admins, Agents and Light Agents
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
permission_set | integer | Query | false | For custom roles which is available on the Enterprise plan and above. You can only filter by one role ID per request |
role | string | Query | false | Filters the results by role. Possible values are "end-user", "agent", or "admin". Allowed values are "end-user", "agent", or "admin". |
role[] | string | Query | false | Filters the results by more than one role using the format role[]={role}&role[]={role} |
Code Samples
cURL
curl https://{subdomain}.zendesk.com/api/v2/users/count.json \
-v -u {email_address}/token:{api_token}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://example.zendesk.com/api/v2/users/count?permission_set=123&role=agent&role[]=agent"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"
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://example.zendesk.com/api/v2/users/count")
.newBuilder()
.addQueryParameter("permission_set", "123")
.addQueryParameter("role", "agent")
.addQueryParameter("role[]", "agent");
String userCredentials = "your_email_address" + "/token:" + "your_api_token";
String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", basicAuth)
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://example.zendesk.com/api/v2/users/count',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"
},
params: {
'permission_set': '123',
'role': 'agent',
'role[]': 'agent',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
from requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/users/count?permission_set=123&role=agent&role[]=agent"
headers = {
"Content-Type": "application/json",
}
email_address = 'your_email_address'
api_token = 'your_api_token'
# Use basic authentication
auth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(
"GET",
url,
auth=auth,
headers=headers
)
print(response.text)
Ruby
require "net/http"
require "base64"
uri = URI("https://example.zendesk.com/api/v2/users/count")
uri.query = URI.encode_www_form("permission_set": "123", "role": "agent", "role[]": "agent")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
email = "your_email_address"
api_token = "your_api_token"
credentials = "#{email}/token:#{api_token}"
encoded_credentials = Base64.strict_encode64(credentials)
request["Authorization"] = "Basic #{encoded_credentials}"
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
{
"count": {
"refreshed_at": "2020-04-06T02:18:17Z",
"value": 102
}
}
Show User
GET /api/v2/users/{user_id}
Allowed For
- Agents
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
user_id | integer | Path | true | The id of the user |
Code Samples
cURL
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}.json \
-v -u {email_address}/token:{api_token}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://example.zendesk.com/api/v2/users/35436"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"
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://example.zendesk.com/api/v2/users/35436")
.newBuilder();
String userCredentials = "your_email_address" + "/token:" + "your_api_token";
String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", basicAuth)
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://example.zendesk.com/api/v2/users/35436',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {