OAuth Tokens for Grant Types

Use this API to get access tokens for the following OAuth grant types:

Another OAuth grant type supported by Zendesk is the implicit grant type. However, this grant type doesn't use the API to get access tokens. See Tokens for Implicit Grant Type below.

For more information on the supported OAuth grant types, see Using OAuth authentication with your application in Help Center.

If you're not working with grant types, use the Create Token endpoint in the OAuth Tokens API. The two APIs don't share the same path, JSON format, or request parameters. However, both APIs return access tokens that can be used to authenticate API requests.

JSON format

OAuth tokens for grant types are represented as JSON objects with the following read-only properties:

Name Type Comment
access_token string The access token
token_type string "bearer"
scope string The valid scopes for this token. See Scope below
Example
{
  "access_token": "gErypPlm4dOVgGRvA1ZzMH5MQ3nLo8bo",
  "token_type": "bearer",
  "scope": "read"
}

Create Token for Grant Type

POST https://{subdomain}.zendesk.com/oauth/tokens

Returns an OAuth access token in exchange for one of the following:

Refresh tokens aren't used. An access token doesn't expire but it can be revoked. Use the OAuth Tokens API to list, show, or revoke tokens.

Request parameters

The POST request takes the following parameters, which must be formatted as JSON:

Name Description
grant_type One of "authorization_code" or "password"
code Authorization grant flow only. The authorization code you received from Zendesk after the user granted access. See Handle the user's authorization decision in Help Center
client_id The Unique Identifier specified in an OAuth client in the Support admin interface (Admin > Channels > API > OAuth Clients). See Registering your application with Zendesk
client_secret The Secret specified in an OAuth client in the Support admin interface (Admin > Channels > API > 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 string of space-separated values. See Scope below
Scope

You must specify a scope to control the app's access to Zendesk resources. The "read" scope gives access to GET endpoints. It 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.

For example, 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"

You can fine-tune the scope of the following resources:

  • tickets
  • users
  • auditlogs (read only)
  • organizations
  • hc
  • apps
  • triggers
  • automations
  • targets

The syntax is as follows:

"scope": "resource:scope"

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"

Note: The endpoint returns an access token even if you specify an invalid scope such as "scope": ["read", "write"] (no parentheses). Any request you make with the token will return a "Forbidden" error.

Using curl

Authorization code grant

curl https://{subdomain}.zendesk.com/oauth/tokens \
  -H "Content-Type: application/json" \
  -d '{"grant_type": "authorization_code", "code": "7xqwtlf3rrdj8uyeb1yf",
    "client_id": "acme_rockets", "client_secret": "77f9931747b63f720f9fbc6",
    "redirect_uri": "https://www.example.com/app/grant_decision",
    "scope": "organizations:write read" }' \
  -X POST

Password grant

curl https://{subdomain}.zendesk.com/oauth/tokens \
  -H "Content-Type: application/json" \
  -d '{"grant_type": "password",  "client_id": "acme_rockets",
    "client_secret": "77f9931747b63f720f9fbc6",
    "username": "jdoe@example.com", "password": "r23ssfoal",
    "scope": "organizations:write read" }' \
  -X POST
Example Response
{
  "access_token": "gErypPlm4dOVgGRvA1ZzMH5MQ3nLo8bo",
  "token_type": "bearer",
  "scope": "organizations:write read"
}

Tokens for Implicit Grant Type

The implicit grant flow is similar to the authorization code grant type except that it doesn't use the API to get the access token. If the end user authorizes access, the token is sent immediately in the redirect URL. No endpoint exists to create the token or set its scope. The token grants read and write access to all resources.

To use this grant type, see Implicit grant flow in Using OAuth authentication with your application in Help Center.