Testing the Zendesk Support API with an API token

Support tooling is full of small integrations: a form that opens a ticket, a bot that adds a comment, a sync that tags tickets from your billing system. They all call the Zendesk Support API, and they all break quietly when a field or a permission changes. A short test collection catches that before customers do.

Step 1: Token and environment

In Admin Center, Apps and integrations ▸ APIs ▸ Zendesk API, turn on token access and add a token. Use a sandbox account if your plan has one.

VariableValue
baseUrlhttps://yourcompany.zendesk.com/api/v2
zendeskUser[email protected]/token (with the literal /token)
zendeskTokenthe API token, marked as secret

Authorization: Basic auth, username {{zendeskUser}}, password {{zendeskToken}}. The /token suffix tells Zendesk the password is an API token, not the agent's password.

Step 2: Check who you are

HTTP
GET {{baseUrl}}/users/me.json
JavaScript
pm.test('signed in as an agent', () => {
  const user = pm.response.json().user;
  pm.expect(user.role).to.be.oneOf(['agent', 'admin']);
});

If role is end-user or the id is null, the credentials didn't work: Zendesk sometimes answers an anonymous user instead of 401.

Step 3: Create a ticket

HTTP
POST {{baseUrl}}/tickets.json
Content-Type: application/json

{
  "ticket": {
    "subject": "API test {{$timestamp}}",
    "comment": {"body": "Created by the API test collection"},
    "priority": "low",
    "tags": ["api-test"]
  }
}
JavaScript
pm.test('ticket created', () => {
  pm.expect(pm.response.code).to.equal(201);
  const t = pm.response.json().ticket;
  pm.expect(t.status).to.equal('new');
  pm.expect(t.tags).to.include('api-test');
  pm.environment.set('ticketId', String(t.id));
});

Step 4: Add a private comment and solve it

HTTP
PUT {{baseUrl}}/tickets/{{ticketId}}.json
Content-Type: application/json

{"ticket": {"status": "solved", "comment": {"body": "Closing the test ticket", "public": false}}}

A comment is added by updating the ticket. public: false makes it an internal note, which is what automated comments usually should be. Solving needs an assignee in some configurations; if the update answers 422, the body's details field says which rule refused it.

Step 5: Pagination

HTTP
GET {{baseUrl}}/tickets.json?page[size]=100
JavaScript
const body = pm.response.json();
pm.test('cursor pagination', () => {
  pm.expect(body).to.have.property('meta');
  pm.expect(body.meta).to.have.property('has_more');
});
if (body.meta.has_more) pm.environment.set('nextPage', body.links.next);

Prefer cursor pagination over the older page= offset style: it's faster, and offset pagination is limited on large lists.

Step 6: Rate limits

Zendesk limits requests per minute by plan. Over the limit, it answers 429 with Retry-After. In a bulk run, add --delay, and test your own integration's retry handling against a mock: simulate error states with mock servers.

Clean up with DELETE {{baseUrl}}/tickets/{{ticketId}}.json (204), so the test tickets don't pile up in reports.