---
title: "PagerDuty"
description: "Open PagerDuty incidents from TRUSTIVAN through the Events API v2, deduplicated per finding, and resolved when the finding is resolved or suppressed."
---

TRUSTIVAN sends events to a PagerDuty service through the **Events API v2**,
with the service's integration key. It is not a PagerDuty app from the
marketplace, and nothing in PagerDuty flows back: acknowledging or resolving an
incident in PagerDuty does not change the finding in TRUSTIVAN.

What it does do is keep the two in step from TRUSTIVAN's side. The same fact
always reaches the same incident, and a finding that is resolved or suppressed
in TRUSTIVAN resolves its incident.

## Prerequisites

- **An integration key.** In PagerDuty, open the service, then **Integrations →
  Add an integration → Events API V2**, and copy the **Integration Key**. It is
  32 characters; a shorter paste is refused when you save.
- **Your account's region.** An EU account sends to `events.eu.pagerduty.com`
  and needs `"region": "eu"`. Anything else is `us`, the default.
- **An administrator of the TRUSTIVAN organization**, signed in with `curl` so
  `cookies.txt` holds the session (see the [quickstart](/getting-started/quickstart)).
  Changing notifications needs `webhooks:manage`, which an API key cannot hold.
- **A plan that includes webhooks.**

## Create the destination

```bash
curl -s -X POST https://app.trustivan.com/api/v1/notification-targets \
  -H 'Content-Type: application/json' \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
  -d '{
        "name": "appsec-pager",
        "channel": "pagerduty",
        "secret": "<32-character integration key>",
        "config": { "region": "us" },
        "events": ["verdict.recorded", "finding.state_changed"],
        "min_severity": "high"
      }'
```

The host is fixed: TRUSTIVAN sends only to `events.pagerduty.com` or
`events.eu.pagerduty.com`, chosen by `region`, so there is no `url`.

## What opens and closes an incident

A PagerDuty destination accepts three events. `finding.sla_breached` and
`audit.recorded` are refused when you save: neither names one fact, so each
would open a new incident every time.

| Event | Sent when | Incident key | Closed when |
|---|---|---|---|
| `scan.completed` | A scan found new critical or high findings | The scan | Never: resolve it in PagerDuty |
| `verdict.recorded` | A verdict blocks a deployment | The verdict | Never: resolve it in PagerDuty |
| `finding.state_changed` | A finding is reopened or has its status changed | The finding's fingerprint, stable across rescans | The finding is resolved or suppressed |

A finding that is resolved and then reopened within 30 days does not page
again: TRUSTIVAN still holds the earlier delivery for that fact.

TRUSTIVAN severities map to PagerDuty's as follows. A blocking verdict has no
severity of its own, so it is sent as `warning` and passes any `min_severity`
filter.

| TRUSTIVAN | PagerDuty |
|---|---|
| `critical` | `critical` |
| `high` | `error` |
| `medium`, or none | `warning` |
| `low`, `info` | `info` |

The incident's summary is the event's one-line description. Its source is the
image or repository for a scan or a verdict, and the vulnerability identifier
for a finding. `custom_details` carries the event name, the original severity
and whether it blocks, and the incident links back to the asset in TRUSTIVAN.

## Test it

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/notification-targets/$TARGET_ID/test" \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')"

curl -s "https://app.trustivan.com/api/v1/notification-targets/$TARGET_ID" -b cookies.txt \
  | jq '.target | {enabled, last_success_at, last_error}'
```

The test sends a real event, so it opens a real `info` incident on the service
titled "Test notification from TRUSTIVAN". Resolve it in PagerDuty.

## Troubleshooting

| Symptom | Cause |
|---|---|
| `400` about the key's length | The integration key is not 32 characters. Copy it again from the Events API V2 integration |
| `400` naming an event | The event is one PagerDuty does not accept. Use `scan.completed`, `verdict.recorded` or `finding.state_changed` |
| `400` about `region` | `region` is `us` or `eu`, not a hostname |
| `last_error` with a `400` from PagerDuty | The key belongs to a different region, or to an integration that is not Events API V2 |
| A resolved finding left its incident open | The incident was opened by `scan.completed` or `verdict.recorded`, which are never resolved automatically |
| The destination was disabled automatically | Deliveries failed repeatedly. Fix the cause, then `PATCH` it with `{"enabled": true}` |

## See also

- [Send notifications to Slack, Jira and other tools](/how-to/configure-notifications):
  every channel, field and limit
- [Jira](/integrations/jira): the same open-and-close behaviour, as issues
- [Gate a pipeline on a policy](/tutorials/gate-a-pipeline)
