PagerDuty
Query and create PagerDuty incidents and services through the official
PagerDuty REST API
(https://api.pagerduty.com). Standard-library Python only — no external
dependencies.
What it does
Branches on an operation input and makes one authenticated REST call.
Every request sends:
Authorization: Token token=<apiKey>
Accept: application/vnd.pagerduty+json;version=2
The full JSON response body is returned in result, and the HTTP status in
status. Non-2xx responses are returned (not thrown) so callers can inspect
PagerDuty's error payload; transport failures fail the step.
Operations
| operation | Method & endpoint | Required inputs |
|---|---|---|
list_incidents |
GET /incidents |
apiKey (optional: statuses, limit) |
get_incident |
GET /incidents/{id} |
apiKey, incidentId |
list_services |
GET /services |
apiKey (optional: limit) |
get_service |
GET /services/{id} |
apiKey, serviceId |
create_incident |
POST /incidents |
apiKey, serviceId, title, from (optional: urgency) |
Notes:
- list_incidents statuses is a comma-separated filter:
triggered,acknowledged,resolved.
- create_incident also sends a From: <email> header (a valid PagerDuty user
email) and Content-Type: application/json, as PagerDuty requires for writes.
- urgency (create) is optional: high or low.
Getting the apiKey
Use a PagerDuty REST API access key:
- Account-level (read/write or read-only): PagerDuty web app → Integrations → API Access Keys → Create New API Key.
- Personal key: click your avatar → My Profile → User Settings → Create API User Token.
The key is passed verbatim into the Authorization: Token token=<apiKey>
header. Treat it as a secret.
Usage examples
List the most recent triggered/acknowledged incidents:
pagerduty apiKey=<KEY> operation=list_incidents statuses=triggered,acknowledged limit=10
Open a new high-urgency incident on a service:
pagerduty apiKey=<KEY> operation=create_incident \
serviceId=PIJ90N7 \
title="Checkout latency over SLO" \
[email protected] \
urgency=high
Look up a single incident by ID:
pagerduty apiKey=<KEY> operation=get_incident incidentId=PT4KHLK