Test a support agent with a Zendesk API mock.

A local Zendesk Support API for your support agent’s tests. Replies and internal notes stay on the ticket, so a test can check which ticket the agent answered.

See the example
Acme SupportOpen

Monthly CSV export is empty #4101

erin.walsh@ridgeway-robotics.example

  • EErin WalshYesterday

    Our monthly CSV export has been empty since Monday.

Acme Support replied

Hi Erin, the fix for the empty CSV export ships on Thursday.

Ticket #4101 after the fixed agent runs. Her invoice ticket, #4102, has no new reply. Starting data and checks from scene.yaml.

An agent replied on the wrong ticket

Erin Walsh at Ridgeway Robotics has two open tickets: her monthly CSV export is empty, and, since three hours ago, her invoice shows the wrong billing address. The agent was told to answer the CSV ticket. It searched her open tickets and replied on the first result, the newest one: the invoice.

Both versions post a reply and every call succeeds, so only a check on which ticket catches it. Changing one line in the agent makes both checks pass, with the test unchanged.

Ticket check3 trials / version
CheckOriginal agentFixed agent
Replied on the CSV ticket0 of 33 of 3
Left the invoice ticket alone0 of 33 of 3

Scripted agent, no model. Recorded with CLI 0.4.74.

The one-line fix

agent.mjs
- const ticket = results[0];+ const ticket = results.find(ticket => ticket.subject.includes('CSV'));

Run it yourself

Save agent.mjs and scene.yaml in an empty directory. You need Node.js 24.

npm install -g @ancha-labs/cli
ancha init --agent "node agent.mjs"
ancha run scene.yaml --local -n 3
ancha baseline save before
# change results[0] to results.find(ticket => ticket.subject.includes('CSV')) in agent.mjs
ancha run scene.yaml --local -n 3 --compare before

Connect your agent to the Zendesk mock

When ancha runs your agent, it sets:

  • ZENDESK_API_URL
  • ZENDESK_EMAIL
  • ZENDESK_API_TOKEN

Point the client you already use at them.

const { ZENDESK_API_URL, ZENDESK_EMAIL, ZENDESK_API_TOKEN } = process.env;
const credentials = `${ZENDESK_EMAIL}/token:${ZENDESK_API_TOKEN}`;
const auth = 'Basic ' + Buffer.from(credentials).toString('base64');

const query = encodeURIComponent('type:ticket status<solved');
const res = await fetch(`${ZENDESK_API_URL}/search.json?query=${query}`, {
  headers: { authorization: auth },
});
const { results } = await res.json();

Locally, ancha runs your agent as an ordinary process, so keep real Zendesk credentials out of its environment.

See all 25 endpoints

brands

GET/api/v2/brands

groups

GET/api/v2/groups

macros

GET/api/v2/macros

organizations

GET/api/v2/organizations
GET/api/v2/organizations/{id}
GET/api/v2/organizations/{id}/tickets
GET/api/v2/organizations/autocomplete
GET/api/v2/organizations/search

search

GET/api/v2/search

tickets

GET/api/v2/tickets
POST/api/v2/tickets
GET/api/v2/tickets/{id}
PUT/api/v2/tickets/{id}
DELETE/api/v2/tickets/{id}
GET/api/v2/tickets/{id}/comments
GET/api/v2/tickets/{id}/macros/{macro_id}/apply
GET/api/v2/tickets/count

users

GET/api/v2/users
POST/api/v2/users
GET/api/v2/users/{id}
GET/api/v2/users/{id}/tickets/requested
GET/api/v2/users/me
GET/api/v2/users/search

views

GET/api/v2/views
GET/api/v2/views/{id}/tickets

Tested together

All 43 tools

Zendesk API mock FAQ

What is a stateful Zendesk API mock?

It keeps data between calls: a reply your agent posts is on the ticket when it reads the ticket again. Ancha’s mock serves the Zendesk Support API v2 for tickets, comments, search, users, organizations, groups, macros and views, with the tickets and customers you seed.

How can I test a Zendesk support agent without a real Zendesk account?

Write the tickets and customers into a test, run the agent with ancha, and check what it did. ancha sets ZENDESK_API_URL, ZENDESK_EMAIL and ZENDESK_API_TOKEN for the agent. The example on this page needs no Zendesk account, API token or model.

How is this different from Zendesk’s own sandbox?

Zendesk’s sandbox is a copy of your Zendesk account for trying out changes, available on some Zendesk plans. Ancha’s mock starts from the tickets a test seeds and needs no Zendesk account, and every trial starts from the same data, so you can run an agent three times and compare.

Can a test use Zendesk with Jira?

Yes. A test can name several tools, and they share one seeded company. The example on the Jira page reads a Zendesk ticket and escalates it in Jira in the same world.

Will a reply reach a real customer?

No. Your agent talks to the ZENDESK_API_URL and token that ancha sets, so every reply it posts lands on the simulated ticket.

Run the example on your machine.

Book a demo

Ancha is not affiliated with Zendesk.