Authentication overview

The Zendesk API utilizes various authentication mechanisms to ensure that all interactions with its services are secure and authorized. This includes verifying the identity of the application or user making a request and granting access based on predefined permissions. Proper authentication is critical for protecting sensitive customer data, maintaining system integrity, and preventing unauthorized access to help desk resources. The choice of authentication method depends on the integration type, the environment (e.g., server-side, client-side), and the required level of user interaction.

Zendesk requires all API requests to be made over HTTPS, encrypting data in transit and protecting against eavesdropping and tampering. This aligns with industry-standard security practices for web APIs, as detailed in the World Wide Web Consortium Content Security Policy Level 3 specification, which emphasizes secure communication protocols.

Supported authentication methods

Zendesk API supports several authentication methods, each suitable for different integration scenarios:

  • API Token: Ideal for server-side applications, scripts, or command-line tools where a user's direct login is not feasible or desired. It involves generating a unique token within the Zendesk admin interface and using it alongside an email address for authentication. This method is common for automated tasks and background processes.
  • OAuth 2.0: Recommended for third-party applications that need to access Zendesk resources on behalf of users without requiring them to share their Zendesk credentials directly with the application. OAuth 2.0 provides a secure, standardized way for applications to obtain limited access to user accounts. Zendesk supports the Authorization Code flow for web applications and the Client Credentials flow for server-to-server integrations. More information on OAuth 2.0 can be found in the OAuth 2.0 specification.
  • Basic Authentication (Email and Password): This method involves sending a user's Zendesk email address and password with each API request. While straightforward, it is generally less secure than API tokens or OAuth 2.0, especially in environments where credentials could be intercepted. Zendesk recommends using API tokens instead of passwords for most programmatic access, reserving basic authentication for specific, controlled scenarios or initial development.

The following table summarizes the primary authentication methods:

Method When to Use Security Level
API Token Server-side apps, scripts, automated tasks, CI/CD pipelines High (requires careful token management)
OAuth 2.0 Third-party integrations, client-side apps, mobile apps, delegated access High (token-based, user consent-driven)
Basic Authentication (Email & Password) Direct user access (less recommended), early-stage development, specific internal tools Medium (less secure due to repeated password transmission)

Getting your credentials

The process for obtaining authentication credentials for the Zendesk API varies depending on the chosen method:

API Tokens

  1. Log in to your Zendesk Support account as an administrator.
  2. Navigate to Admin > Channels > API.
  3. Enable token access if it's not already enabled.
  4. Click the Add API token button.
  5. Copy the generated token immediately, as it will only be shown once. If you lose it, you'll need to generate a new one.

For detailed steps, refer to the Zendesk API token usage documentation.

OAuth 2.0 Client Credentials

  1. Log in to your Zendesk Support account as an administrator.
  2. Navigate to Admin > Channels > API.
  3. Click on the OAuth Clients tab.
  4. Click the Add OAuth client button.
  5. Provide a Client Name, Description, and redirect Redirect URLs. The redirect URL is where the user is sent after authorizing your application.
  6. Once created, Zendesk will provide a Client ID and a Client Secret. The client secret should be treated with the same confidentiality as a password.

For comprehensive guidance on setting up OAuth clients and understanding flows, consult the Zendesk OAuth authorization guide.

Basic Authentication (Email and Password)

For basic authentication, you will use the email address and password of an existing Zendesk user with appropriate API access permissions. No special setup is required beyond ensuring the user exists and has the necessary roles. However, as noted, API tokens are generally preferred for programmatic access due to enhanced security and revocability.

Authenticated request example

Here's an example of an authenticated API request using an API token to list tickets. Replace {your_subdomain}, {your_email}, and {your_api_token} with your actual credentials.

curl https://{your_subdomain}.zendesk.com/api/v2/tickets.json \
  -v -u {your_email}/token:{your_api_token}

For OAuth 2.0, after obtaining an access token, you would include it in the Authorization header:

curl https://{your_subdomain}.zendesk.com/api/v2/tickets.json \
  -H "Authorization: Bearer {your_access_token}"

These examples illustrate common patterns for interacting with the Zendesk API once authenticated. The Zendesk API reference provides further examples for specific endpoints and operations.

Security best practices

Adhering to security best practices is essential when integrating with the Zendesk API to protect your data and maintain the integrity of your customer service operations:

  • Use HTTPS for all API interactions: Ensure all requests are sent over HTTPS to encrypt data in transit. Zendesk enforces this, but it's a fundamental principle for any API integration.
  • Protect API tokens and secrets: Treat API tokens, OAuth client secrets, and user passwords as highly sensitive information. Store them securely, preferably in environment variables or a dedicated secret management system, not directly in source code.
  • Implement the Principle of Least Privilege: Grant only the minimum necessary permissions to the API user or OAuth client. For example, if an integration only needs to read tickets, do not grant it permission to create or delete users.
  • Regularly rotate API tokens: Periodically generate new API tokens and revoke old ones. This minimizes the impact if a token is compromised.
  • Implement robust error handling: Design your application to handle API errors gracefully, particularly authentication failures, without exposing sensitive information.
  • Monitor API activity: Keep an eye on your API logs for unusual activity or excessive failed authentication attempts, which could indicate a security incident.
  • Validate input: Always validate and sanitize any data sent to the Zendesk API to prevent injection attacks or malformed requests.
  • Secure OAuth Redirect URIs: For OAuth integrations, register only specific, secure redirect URIs. Avoid using localhost or wildcards in production environments to prevent authorization code interception attacks. The IETF RFC 6749 provides guidelines for secure redirect URI registration.
  • Educate developers: Ensure that all developers working with your Zendesk API integrations are aware of these security protocols and best practices.