0

Delete lead ads subscription

by
Published Dec 20, 2024

Delete an existing lead ads webhook subscription by ID. - Only requests for the OWNER or ADMIN of the ad_account will be allowed. This endpoint is currently in beta and not available to all apps. Learn more.

Script pinterest Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Pinterest = {
3
  token: string;
4
};
5
/**
6
 * Delete lead ads subscription
7
 * Delete an existing lead ads webhook subscription by ID.
8
- Only requests for the OWNER or ADMIN of the ad_account will be allowed.
9

10
This endpoint is currently in beta and not available to all apps. Learn more.
11
 */
12
export async function main(
13
  auth: Pinterest,
14
  ad_account_id: string,
15
  subscription_id: string,
16
) {
17
  const url = new URL(
18
    `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/leads/subscriptions/${subscription_id}`,
19
  );
20

21
  const response = await fetch(url, {
22
    method: "DELETE",
23
    headers: {
24
      Authorization: "Bearer " + auth.token,
25
    },
26
    body: undefined,
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