0

Unlink Locations

by
Published Oct 17, 2025
Script tomorrow Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Tomorrow = {
3
  apiKey: string;
4
};
5
/**
6
 * Unlink Locations
7
 *
8
 */
9
export async function main(
10
  auth: Tomorrow,
11
  alertId: string,
12
  body: { locations: string[] },
13
  Accept_Encoding?: string,
14
) {
15
  const url = new URL(
16
    `https://api.tomorrow.io/v4/alerts/${alertId}/locations/unlink`,
17
  );
18

19
  const response = await fetch(url, {
20
    method: "POST",
21
    headers: {
22
      ...(Accept_Encoding ? { "Accept-Encoding": Accept_Encoding } : {}),
23
      "Content-Type": "application/json",
24
      ApiKey: auth.apiKey,
25
    },
26
    body: JSON.stringify(body),
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.json();
33
}
34