0

Delete a Check

by
Published Dec 20, 2024

To delete an Uptime check, send a DELETE request to `/v2/uptime/checks/$CHECK_ID`. A 204 status code with no body will be returned in response to a successful request. Deleting a check will also delete alerts associated with the check.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * Delete a Check
7
 * To delete an Uptime check, send a DELETE request to `/v2/uptime/checks/$CHECK_ID`. A 204 status
8
code with no body will be returned in response to a successful request.
9

10

11
Deleting a check will also delete alerts associated with the check.
12

13
 */
14
export async function main(auth: Digitalocean, check_id: string) {
15
  const url = new URL(
16
    `https://api.digitalocean.com/v2/uptime/checks/${check_id}`,
17
  );
18

19
  const response = await fetch(url, {
20
    method: "DELETE",
21
    headers: {
22
      Authorization: "Bearer " + auth.token,
23
    },
24
    body: undefined,
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.json();
31
}
32