POST /oauth/tokens
Returns an OAuth access token in exchange for one of the following:
- an authorization code
- a refresh token
- a client secret
Note: The password grant type flow, which used a Zendesk username and password to get an access token, has been deprecated and is highly discouraged.
To revoke an access token, see Revoke Token.
Request parameters
The POST request takes the following parameters, which must be formatted as JSON:
| Name | Description |
|---|---|
| grant_type | "authorization_code", "refresh_token", or "client_credentials" |
| code | Authorization grant flow only. The authorization code you received from Zendesk after the user granted access. The code is valid for only 120 seconds. See Handle the user's authorization decision in Zendesk help |
| client_id | The Identifier value specified in an OAuth client in the Zendesk Admin Center (Apps and integrations > APIs > OAuth clients). See Registering your application with Zendesk |
| client_secret | The Secret value specified in an OAuth client in the Admin Center (Apps and integrations > APIs > OAuth clients). See Registering your application with Zendesk |
| redirect_uri | Authorization grant flow only. The redirect URL you specified when you sent the user to the Zendesk authorization page. For ID purposes only. See Send the user to the Zendesk authorization page |
| scope | Valid scope for this token. A space-separated string of scope values. Must be within the client's configured allowed scopes, if set. See Scope below |
| expires_in | Number of seconds the access token is valid. Must be greater than or equal to 300 seconds (5 minutes) and less than or equal to 172,800 seconds (2 days), or less than refresh_token_expires_in, whichever is the shorter. Defaults to null |
| refresh_token_expires_in | Number of seconds the refresh token is valid. Must be greater than or equal to 604,800 seconds (7 days) or expires_in (if given), and less than or equal to 7,776,000 seconds (90 days). Defaults to 2,592,000 seconds (30 days) |
| refresh_token | A valid refresh token. See Replacing expired access tokens |
Authorization code example
const tokenResponse = await axios.post(
"https://{subdomain}.zendesk.com/oauth/tokens",
{
grant_type: "authorization_code",
code: AUTHORIZATION_CODE,
client_id: ZENDESK_CLIENT_ID,
redirect_uri: REDIRECT_URI_PKCE,
scope: "tickets:read users:read",
code_verifier: CODE_VERIFIER,
expires_in: 86400,
refresh_token_expires_in: 604800,
},
{ headers: { "Content-Type": "application/json" } }
);
Refresh token example
const tokenResponse = await axios.post(
"https://{subdomain}.zendesk.com/oauth/tokens",
{
grant_type: "refresh_token",
refresh_token: REFRESH_TOKEN,
client_id: ZENDESK_CLIENT_ID,
client_secret: ZENDESK_CLIENT_SECRET,
scope: "tickets:write",
expires_in: 86400,
refresh_token_expires_in: 604800,
},
{ headers: { "Content-Type": "application/json" } }
);
Client credentials example
const tokenResponse = await axios.post(
"https://{subdomain}.zendesk.com/oauth/tokens",
{
grant_type: "client_credentials",
client_id: ZENDESK_CLIENT_ID,
client_secret: ZENDESK_CLIENT_SECRET,
scope: "tickets:write",
expires_in: 86400
},
{ headers: { "Content-Type": "application/json" } }
);
Scope
You must specify a scope to control the app's access to Zendesk resources. The "read" scope gives access to GET endpoints and includes permission to sideload related resources. The "write" scope gives access to POST, PUT, and DELETE endpoints for creating, updating, and deleting resources.
Note: Don't confuse the scope parameter (singular) with the scopes parameter (plural) for non-grant-type tokens described in OAuth Tokens.
The "impersonate" scope allows a Zendesk admin to make requests on behalf of end users. See Making API requests on behalf of end users.
Broad scopes
The following parameter gives read access to all resources:
"scope": "read"
The following parameter gives read and write access to all resources:
"scope": "read write"
Resource-specific scopes
You can fine-tune access using resource-specific scopes. The syntax is as follows:
"scope": "resource:action"
For example, the following parameter restricts the scope to only reading tickets:
"scope": "tickets:read"
To give read and write access to a resource, specify both scopes:
"scope": "users:read users:write"
To give write access only to one resource, such as organizations, and read access to everything else:
"scope": "organizations:write read"
Scope errors
There are two distinct scope-related error cases to be aware of:
- Unrecognized scope string: If you specify a scope value that doesn't exist (for example, a typo such as
"scope": ["read", "write"]using an array instead of a string), the endpoint still creates an access token. However, any API request made with that token will return a403 Forbiddenerror. - Scope outside client's allowed scopes: If the OAuth client has allowed scopes configured and you request a scope not included in that list, the endpoint returns
400 Bad Requestwith aninvalid_scopeerror and no token is created.
Available scopes
| Scope | Description |
|---|---|
read | Read all data. Gives access to GET endpoints, including permission to sideload related resources. |
write | Write all data. Gives access to POST, PUT, and DELETE endpoints. |
impersonate | Allows Zendesk Support admins to make requests on behalf of end users. See Making API requests on behalf of end users. |
account_settings:read | View account settings. Includes account configuration, ticket and user fields, and workspaces. |
account_settings:write | Create, edit, and delete account settings. Includes account configuration, ticket and user fields, and workspaces. |
ai_agents:chat | Chat with AI agents. Includes sending messages and receiving responses via the Zendesk Developers API. |
apps:read | View installed apps and their settings. Includes which apps are installed and each app's settings. |
apps:write | Install, configure, and remove apps. Includes installing and uninstalling apps, changing settings, and uploading custom app packages. |
auditlogs:read | View audit logs. Includes the account-wide record of changes: who changed what and when. Read only. |
automations:read | View automations and their details. |
automations:write | Create, edit, and delete automations. |
brands:read | View brands and their agent assignments. |
brands:write | Create, edit, and delete brands and their agent assignments. |
custom_objects:read | View custom objects. Includes custom object definitions and record attachments. |
custom_objects:write | Create, edit, and delete custom objects. Includes definitions and record attachments. |
deletion_schedules:read | View deletion schedules. Includes data retention policies that automatically delete tickets, users, and other data. |
deletion_schedules:write | Delete deletion schedules. Includes deleting data retention policies. |
dynamic_content:read | View dynamic content items and language variants. |
dynamic_content:write | Create, edit, and delete dynamic content items and language variants. |
groups:read | View groups and their memberships. |
groups:write | Create, edit, and delete groups and their memberships. |
hc:read | View Help Center content. Includes articles, sections, categories, community posts and comments. |
hc:write | Create, edit, and delete Help Center content. Includes articles, sections, categories, community posts and comments. |
macros:read | View macros, their categories, and attachments. |
macros:write | Create, edit, and delete macros and their attachments. |
organizations:read | View organizations and their details. Includes memberships, subscriptions, and merge history. |
organizations:write | Create, edit, and delete organizations and manage their memberships. Includes adding and removing users, managing subscriptions, and merging organizations. |
requests:read | View support requests and their comments. |
requests:write | Submit and edit support requests. Includes creating new requests and adding to existing ones. |
satisfaction_ratings:read | View satisfaction ratings, scores, and reasons. |
satisfaction_ratings:write | Submit satisfaction ratings. Includes rating a ticket good or bad with an optional reason. |
security:read | View security and sign-in settings. Includes password policy, session timeouts, IP restrictions, and SSO configuration. Read only. |
sla_policies:read | View SLA and group SLA policies. |
sla_policies:write | Create, edit, delete, and reorder SLA and group SLA policies. |
targets:read | View targets and their delivery failures. |
targets:write | Create, edit, and delete targets. |
themes:read | View Guide themes and their files. |
themes:write | Create, edit, and delete Guide themes. Includes importing, updating, publishing, exporting, and deleting themes. |
ticket_attachments:read | View files attached to tickets. |
ticket_attachments:write | Upload, edit, and delete ticket attachments. Includes uploading files, updating and deleting attachments, and redacting them. |
ticket_views:read | View ticket views and the tickets they return. |
ticket_views:write | Create, edit, and delete ticket views. |
tickets:read | View tickets. Includes ticket contents, comments and conversation history, tags, forms and fields, audits, events, and metrics. |
tickets:write | Create, edit, and delete tickets. Includes adding comments, tags, merging tickets, marking spam, attachments, forms, and custom statuses. |
triggers:read | View triggers, trigger categories, and their revision history. |
triggers:write | Create, edit, delete, and reorder triggers and trigger categories. |
users:read | View users. Includes identities, active sessions, group, organization, and brand memberships, roles, and settings. |
users:write | Create, edit, and delete users and manage their access. Includes resetting passwords, ending sessions, adding identities, changing memberships, and managing custom roles. |
webhooks:read | View webhooks and their activity history. |
webhooks:write | Create, edit, test, and delete webhooks. |
any_channel:write | Push messages from an external channel into Zendesk. Includes creating tickets, comments, and users from an integrated channel. Write only. |
web_widget:write | Edit Web Widget settings and configuration. Write only. |
zis:read | View private integrations. Includes configurations, connections, and inbound webhooks. |
zis:write | Create, edit, and delete private integrations. Includes configurations, connections, and inbound webhooks. |
Servers
- https://{subdomain}.{domain}.com
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.