0

Acknowledge Event (Events API v2)

by
Published 4 days ago

Acknowledge an alert previously triggered via the Events API v2, identified by its dedup_key. Acknowledging pauses escalations for the alert.

Script pagerduty Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 5 days ago
1
//native
2

3
/**
4
 * Acknowledge Event (Events API v2)
5
 * Acknowledge an alert previously triggered via the Events API v2, identified by its dedup_key. Acknowledging pauses escalations for the alert.
6
 */
7
export async function main(auth: RT.PagerdutyEvents, dedup_key: string) {
8
  const response = await fetch("https://events.pagerduty.com/v2/enqueue", {
9
    method: "POST",
10
    headers: {
11
      "Content-Type": "application/json",
12
      Accept: "application/json",
13
    },
14
    body: JSON.stringify({
15
      routing_key: auth.routing_key,
16
      event_action: "acknowledge",
17
      dedup_key,
18
    }),
19
  })
20

21
  if (!response.ok) {
22
    throw new Error(`${response.status} ${await response.text()}`)
23
  }
24

25
  return await response.json()
26
}
27