0

Delete webhooks by ID

by
Published Nov 2, 2023

Removes webhooks by ID. Only webhooks registered by the calling app are removed. If webhooks created by other apps are specified, they are ignored. **[Permissions](#permissions) required:** Only [Connect](https://developer.atlassian.com/cloud/jira/platform/#connect-apps) and [OAuth 2.0](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps) apps can use this operation.

Script jira Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 416 days ago
1
type Jira = {
2
  username: string;
3
  password: string;
4
  domain: string;
5
};
6
/**
7
 * Delete webhooks by ID
8
 * Removes webhooks by ID. Only webhooks registered by the calling app are removed. If webhooks created by other apps are specified, they are ignored.
9

10
**[Permissions](#permissions) required:** Only [Connect](https://developer.atlassian.com/cloud/jira/platform/#connect-apps) and [OAuth 2.0](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps) apps can use this operation.
11
 */
12
export async function main(auth: Jira, body: { webhookIds: number[] }) {
13
  const url = new URL(
14
    `https://${auth.domain}.atlassian.net/rest/api/2/webhook`
15
  );
16

17
  const response = await fetch(url, {
18
    method: "DELETE",
19
    headers: {
20
      "Content-Type": "application/json",
21
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
22
    },
23
    body: JSON.stringify(body),
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.text();
30
}
31