A request is an end user's perspective on a ticket. End users can only see public comments and certain fields of a ticket. Use this API to let end users view, update, and create tickets they have access to.

You can sideload some resources with requests. See Requests in Supported Endpoints in Side-loading.

Authentication

End users can use the Requests API.

Note: An end user won't be able to view their requests if the end user added an email identity (an email address associated with a Zendesk profile) after September 17, 2017, and didn't verify the email address. The problem is flagged by the API with a 403 response. See Verifying a user's email address in the Support Help Center.

Anonymous requests are supported for ticket creation but can be disabled by administrators. These anonymous requests have a rate limit of 5 requests per hour for trial accounts. See Create Request below.

Admins and agents are treated as end users when using the Requests endpoint.

Multibrand accounts

On the Enterprise plan and above, a Support account can have more than one brand. See Understanding how Multibrand works in your account in the Support Help Center.

If you have multiple brands in your account, the Requests API only returns tickets for the brand specified in the API path. It doesn't return all tickets in the account. In the API path, the brand is specified by the subdomain. For example, a GET request to https://omniwear.zendesk.com/api/v2/requests.json only returns tickets for the Omniwear brand, even if Omniwear is the default brand.

Status (legacy) and Custom Ticket Status

See Status (legacy) and Custom Ticket Status in Tickets

JSON format

Requests are represented as JSON objects with the following properties:

NameTypeRead-onlyMandatoryDescription
assignee_idintegertruefalseThe id of the assignee if the field is visible to end users
can_be_solved_by_mebooleantruefalseIf true, an end user can mark the request as solved. See Update Request
collaborator_idsarraytruefalseThe ids of users currently CC'ed on the ticket
created_atstringtruefalseWhen this record was created
custom_fieldsarrayfalsefalseCustom fields for the request. See Setting custom field values in the Tickets doc
custom_status_idintegerfalsefalseThe custom ticket status id of the ticket
descriptionstringtruefalseRead-only first comment on the request. When creating a request, use comment to set the description
due_atstringfalsefalseWhen the task is due (only applies if the request is of type "task")
email_cc_idsarraytruefalseThe ids of users who are currently email CCs on the ticket. See CCs and followers resources in the Support Help Center
followup_source_idintegertruefalseThe id of the original ticket if this request is a follow-up ticket. See Create Request
group_idintegertruefalseThe id of the assigned group if the field is visible to end users
idintegertruefalseAutomatically assigned when creating requests
is_publicbooleantruefalseIs true if any comments are public, false otherwise
organization_idintegertruefalseThe organization of the requester
prioritystringfalsefalseThe priority of the request, "low", "normal", "high", "urgent"
recipientstringfalsefalseThe original recipient e-mail address of the request
requester_idintegertruefalseThe id of the requester
solvedbooleanfalsefalseWhether or not request is solved (an end user can set this if "can_be_solved_by_me", above, is true for that user)
statusstringfalsefalseThe state of the request, "new", "open", "pending", "hold", "solved", "closed"
subjectstringfalsetrueThe value of the subject field for this request if the subject field is visible to end users; a truncated version of the description otherwise
ticket_form_idintegerfalsefalseThe numeric id of the ticket form associated with this request if the form is visible to end users - only applicable for enterprise accounts
typestringfalsefalseThe type of the request, "question", "incident", "problem", "task"
updated_atstringtruefalseWhen this record last got updated
urlstringtruefalseThe API url of this request
viaobjectfalsefalseDescribes how the object was created. See the Via object reference

Request Comments

Comments represent the public conversation between requesters, collaborators and agents on a request.

Request comments have the following properties:

NameTypeRead-onlyComment
idintegeryesAutomatically assigned when the comment is created
typestringyes"Comment" or "VoiceComment"
request_idintegeryesThe id of the request
bodystringnoThe actual comment made by the author
html_bodystringyesThe actual comment made by the author formatted as HTML
plain_bodystringyesThe comment formatted as plain text
publicbooleanyesIf true, the comment is public
author_idintegeryesThe id of the author
attachmentsarrayyesRead-only list of attachments to the comment. See Attaching files
uploadsarrayno**On create only. List of tokens received after uploading files to attach
created_atdateyesWhen this comment was created

Request Comment Example

{  "id": 1274,  "type": "Comment",  "body": "Thanks for your help!",  "html_body": "<p>Thanks for your help!</p>",  "author_id": 1,  "attachments": [    {      "id":           498483,      "name":         "crash.log",      "content_url":  "https://company.zendesk.com/attachments/crash.log",      "content_type": "text/plain",      "size":         2532,      "thumbnails":   []    }  ],  "created_at": "2009-07-20T22:55:29Z"}

Example

{  "assignee_id": 72983,  "can_be_solved_by_me": false,  "collaborator_ids": [],  "created_at": "2009-07-20T22:55:29Z",  "description": "The fire is very colorful.",  "due_at": "2011-05-24T12:00:00Z",  "group_id": 8665,  "id": 35436,  "organization_id": 509974,  "priority": "normal",  "requester_id": 1462,  "status": "open",  "subject": "Help, my printer is on fire!",  "ticket_form_id": 2,  "type": "problem",  "updated_at": "2011-05-05T10:38:52Z",  "url": "https://company.zendesk.com/api/v2/requests/35436.json",  "via": {    "channel": "web"  }}

List Requests

  • GET /api/v2/requests
  • GET /api/v2/requests.json?status=hold,open
  • GET /api/v2/requests/open.json
  • GET /api/v2/requests/solved.json
  • GET /api/v2/requests/ccd.json
  • GET /api/v2/users/{user_id}/requests.json
  • GET /api/v2/organizations/{organization_id}/requests.json

Allowed for

  • End Users

Pagination

  • Cursor pagination (recommended)
  • Offset pagination

See Pagination.

Parameters

NameTypeInRequiredDescription
sort_bystringQueryfalsePossible values are "updated_at", "created_at"
sort_orderstringQueryfalseOne of "asc", "desc". Defaults to "asc"

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/requests.json \  -v -u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://example.zendesk.com/api/v2/requests?sort_by=&sort_order="	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/requests")		.newBuilder()		.addQueryParameter("sort_by", "")		.addQueryParameter("sort_order", "");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/requests',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },  params: {    'sort_by': '',    'sort_order': '',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/requests?sort_by=&sort_order="headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = 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/requests")uri.query = URI.encode_www_form("sort_by": "", "sort_order": "")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
{  "requests": [    {      "custom_status_id": 123,      "description": "My printer is on fire!",      "id": 33,      "status": "open",      "subject": "Help!"    },    {      "custom_status_id": 234,      "description": "I can't find my keys",      "id": 34,      "status": "closed",      "subject": "Help!"    }  ]}

Search Requests

  • GET /api/v2/requests/search

Examples:

  • GET /api/v2/requests/search.json?query=printer
  • GET /api/v2/requests/search.json?query=printer&organization_id=1
  • GET /api/v2/requests/search.json?query=printer&cc_id=true
  • GET /api/v2/requests/search.json?query=printer&status=hold,open

Pagination

  • Offset pagination only

See Using Offset Pagination.

Results limit

The Search Requests endpoint returns up to 1,000 results per query, with a maximum of 100 results per page. See Pagination. If you request a page past the limit (page=11 at 100 results per page), a 422 Insufficient Resource Error is returned.

Allowed For

  • End Users

Parameters

NameTypeInRequiredDescription
querystringQueryfalseThe syntax and matching logic for the string is detailed in the Zendesk Support search reference. See also Query basics in the Tickets API doc.

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/requests/search.json?query={search_string} \  -v -u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://example.zendesk.com/api/v2/requests/search?query="	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/requests/search")		.newBuilder()		.addQueryParameter("query", "");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/requests/search',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },  params: {    'query': '',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/requests/search?query="headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = 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/requests/search")uri.query = URI.encode_www_form("query": "")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
{  "requests": [    {      "custom_status_id": 123,      "description": "My printer is on fire!",      "id": 33,      "status": "open",      "subject": "Help!"    },    {      "custom_status_id": 234,      "description": "I can't find my keys",      "id": 34,      "status": "closed",      "subject": "Help!"    }  ]}

Show Request

  • GET /api/v2/requests/{request_id}

Sideloads

The following sideloads are supported:

NameWill sideload
usersThe email ccs for a request by side-loading users

Allowed For

  • End Users

Parameters

NameTypeInRequiredDescription
request_idintegerPathtrueThe ID of the request

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/requests/{request_id}.json \  -v -u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://example.zendesk.com/api/v2/requests/33"	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/requests/33")		.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/requests/33',  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) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/requests/33"headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = 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/requests/33")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
{  "request": {    "custom_status_id": 123,    "description": "My printer is on fire!",    "id": 33,    "status": "open",    "subject": "Help!"  }}

Create Request

  • POST /api/v2/requests

Accepts a request object that sets one or more properties.

Allowed for

  • End users
  • Anonymous users (rate limit of 5 requests per hour for trial accounts)

Additional properties

In addition to the writable request properties in the JSON Format table above, you can set the following properties when creating a request.

NameTypeMandatoryComment
commentobjectyesDescribes the problem, incident, question, or task. See Request comments
collaboratorsarraynoAdds collaborators (cc's) to the request. An email notification is sent to them when the ticket is created. See Setting collaborators
requesterobjectyes**Required for anonymous requests. Specifies the requester of the anonymous request. See Creating anonymous requests

Creating follow-up requests

Once a ticket is closed (as distinct from solved), it can't be reopened. However, you can create a new request that references the closed ticket. To create the follow-up request, include a via_followup_source_id property in the request object that specifies the closed ticket. The parameter only works with closed tickets. It has no effect with other tickets.

Code Samples

curl

Authenticated request

curl https://{subdomain}.zendesk.com/api/v2/requests.json \  -d '{"request": {"subject": "Help!", "comment": {"body": "My printer is on fire!", "uploads": [...] }}}' \  -v -u {email_address}/token:{api_token} -X POST -H "Content-Type: application/json"
curl

Anonymous request

curl https://{subdomain}.zendesk.com/api/v2/requests.json \  -d '{"request": {"requester": {"name": "Anonymous customer"}, "subject": "Help!", "comment": {"body": "My printer is on fire!" }}}' \  -X POST -H "Content-Type: application/json"
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://example.zendesk.com/api/v2/requests"	method := "POST"	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/requests")		.newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),		"""""");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("POST", body)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'POST',  url: 'https://example.zendesk.com/api/v2/requests',  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) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/requests"headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"POST",	url,	auth=auth,	headers=headers)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/requests")request = Net::HTTP::Post.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)

201 Created
// Status 201 Created
{  "request": {    "custom_status_id": 1,    "description": "My printer is on fire!",    "id": 33,    "status": "new",    "subject": "Help!"  }}

Update Request

  • PUT /api/v2/requests/{request_id}

Updates a request with a comment or collaborators (cc's). The end user who created the request can also use it to mark the request as solved. The endpoint can't be used to update other request attributes.

Writable properties

This endpoint can only update the following properties in the request.

NameTypeRequiredDescription
commentobjectnoAdds a comment to the request. See Request comments
solvedbooleannoMarks the request as solved. Example: {"request": {"solved": "true"}}. End users can mark requests as solved only if the request's can_be_solved_by_me property is true. The property is true only when the ticket is assigned to an agent and the ticket type is not a problem but a question, task, or incident
additional_collaboratorsarraynoAdds collaborators to the request. An email notification is sent to them when the ticket is updated. See Adding collaborators

Allowed For

  • End users

Parameters

NameTypeInRequiredDescription
request_idintegerPathtrueThe ID of the request

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/requests/{id}.json \  -d '{"request": {"comment": {"body": "Thanks!"}}}' \  -v -u {email_address}/token:{api_token} -X PUT -H "Content-Type: application/json"
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://example.zendesk.com/api/v2/requests/33"	method := "PUT"	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/requests/33")		.newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),		"""""");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("PUT", body)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'PUT',  url: 'https://example.zendesk.com/api/v2/requests/33',  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) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/requests/33"headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"PUT",	url,	auth=auth,	headers=headers)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/requests/33")request = Net::HTTP::Put.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
{  "request": {    "custom_status_id": 1,    "description": "My printer is on fire!",    "id": 33,    "status": "new",    "subject": "Help!"  }}

Listing Comments

  • GET /api/v2/requests/{request_id}/comments

Pagination

  • Cursor pagination (recommended)
  • Offset pagination

See Pagination.

Sorting

By default, comments are sorted by creation date in ascending order.

When using cursor pagination, use the following parameter to change the sort order:

NameTypeRequiredComments
sortstringnoPossible values are "created_at" (ascending order) or "-created_at" (descending order)

When using offset pagination, use the following parameters to change the sort order:

NameTypeRequiredComments
sort_bystringnoOne of created_at, updated_at
sort_orderstringnoOne of asc, desc

Allowed For

  • End Users

Parameters

NameTypeInRequiredDescription
rolestringQueryfalseOne of "agent", "end_user". If not specified it does not filter
sincestringQueryfalseFilters the comments from the given datetime
request_idintegerPathtrueThe ID of the request

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/requests/{request_id}/comments.json \  -v -u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://example.zendesk.com/api/v2/requests/33/comments?role=&since="	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/requests/33/comments")		.newBuilder()		.addQueryParameter("role", "")		.addQueryParameter("since", "");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/requests/33/comments',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },  params: {    'role': '',    'since': '',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/requests/33/comments?role=&since="headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = 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/requests/33/comments")uri.query = URI.encode_www_form("role": "", "since": "")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
{  "comments": [    {      "body": "Thanks for your help",      "id": 43    }  ]}

Getting Comments

  • GET /api/v2/requests/{request_id}/comments/{ticket_comment_id}

Allowed For

  • End Users

Parameters

NameTypeInRequiredDescription
request_idintegerPathtrueThe ID of the request
ticket_comment_idintegerPathtrueThe ID of the ticket comment

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/requests/{request_id}/comments/{ticket_comment_id}.json \  -v -u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://example.zendesk.com/api/v2/requests/33/comments/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/requests/33/comments/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/requests/33/comments/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) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://example.zendesk.com/api/v2/requests/33/comments/35436"headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = 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/requests/33/comments/35436")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
{  "comment": {    "body": "Thanks!",    "id": 43  }}