Test an on-call agent with a PagerDuty API mock.

A local PagerDuty REST API for your on-call agent’s tests. Acknowledgments and notes stay on the incident, so a test can check which page it took.

See the example
Orders on-call

Open incidents

  • Checkout APItriggered

    Elevated 5xx in staging

  • Orders APIacknowledged

    Requests waiting for database connections

On-call bot added a note to Orders API

Looking into it: requests are waiting for database connections.

The incidents after the fixed agent runs. Starting data and checks from scene.yaml.

An agent acknowledged the wrong incident

Two incidents were open: Checkout API, from staging, twelve minutes old, and Orders API, two minutes old. The agent is on call for the Orders API. It took the first triggered incident in the list, acknowledged Checkout and left the Orders page ringing.

The test checks both incidents after the run: Orders acknowledged, Checkout still triggered.

Incident status3 trials / version
CheckOriginal agentFixed agent
Acknowledged the Orders page0 of 33 of 3
Left the Checkout page alone0 of 33 of 3

Scripted agent, no model. Recorded with CLI 0.4.74.

The one-line fix

agent.mjs
- const page = incidents[0];+ const page = incidents.find(incident => incident.service.summary === 'Orders API');

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 incidents[0] to incidents.find(incident => incident.service.summary === 'Orders API') in agent.mjs
ancha run scene.yaml --local -n 3 --compare before

Connect your agent to the PagerDuty mock

When ancha runs your agent, it sets:

  • PAGERDUTY_API_URL
  • PAGERDUTY_API_TOKEN
  • PAGERDUTY_FROM_EMAIL
  • PAGERDUTY_ROUTING_KEY
  • PAGERDUTY_ROUTING_KEYS
  • PAGERDUTY_SIGNING_SECRET

Point the client you already use at them.

import { api } from '@pagerduty/pdjs';

const pd = api({ token: process.env.PAGERDUTY_API_TOKEN });
const base = process.env.PAGERDUTY_API_URL;

// Pass the full local URL on every call; writes also send From: PAGERDUTY_FROM_EMAIL.
await pd.get('/services', { url: `${base}/services` });

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

See all 20 endpoints

enqueue

POST/v2/enqueue

escalation_policies

GET/escalation_policies
GET/escalation_policies/:id

incidents

GET/incidents
GET/incidents/:id
PUT/incidents/:id
GET/incidents/:id/log_entries
GET/incidents/:id/notes
POST/incidents/:id/notes

oncalls

GET/oncalls

schedules

GET/schedules
GET/schedules/:id
GET/schedules/:id/overrides
POST/schedules/:id/overrides
DELETE/schedules/:id/overrides/:override_id
GET/schedules/:id/users

services

GET/services
GET/services/:id

users

GET/users
GET/users/:id

Tested together

All 43 tools

PagerDuty API mock FAQ

How do I test an on-call agent without real alerts?

Seed the services, escalation policies and incidents in a test, point the agent at Ancha’s PagerDuty endpoint and check each incident’s final status. Nobody gets paged: the incidents exist only in the world.

Can I check how fast my agent acknowledged a page?

Yes. An incident check accepts acknowledged_within and resolved_within, measured on the world’s simulated clock from the incident’s creation.

Can people respond during the test?

Yes. In a living world, scripted people acknowledge or resolve incidents at a set time or when something happens, so you can test an agent that hands off or waits.

Can I use @pagerduty/pdjs?

Yes. It is tested with @pagerduty/pdjs 2.2.4. Pass the full local URL on every call, and send a From header with PAGERDUTY_FROM_EMAIL on writes.

Is this connected to my PagerDuty account?

No. Ancha simulates the PagerDuty API, and your agent talks to it through the PAGERDUTY_API_URL and token that ancha sets.

How is this different from a PagerDuty developer account?

A developer account is a real PagerDuty account: it keeps the incidents earlier runs left in it, and your agent needs a real API key. The mock starts from your test’s data on every run, and your agent connects with the variables ancha sets.

Run the example on your machine.

Book a demo

Ancha is not affiliated with PagerDuty.