0

Delete ads data for ad account in API Sandbox

by
Published Dec 20, 2024

Delete an ad account and all the ads data associated with that account. A string message is returned indicating the status of the delete operation. Note: This endpoint is only allowed in the Pinterest API Sandbox (https://api-sandbox.pinterest.com/v5). Go to /docs/developer-tools/sandbox/ for more information.

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 ads data for ad account in API Sandbox
7
 * Delete an ad account and all the ads data associated with that account.
8
A string message is returned indicating the status of the delete operation.
9

10
Note: This endpoint is only allowed in the Pinterest API Sandbox (https://api-sandbox.pinterest.com/v5).
11
Go to /docs/developer-tools/sandbox/ for more information.
12
 */
13
export async function main(auth: Pinterest, ad_account_id: string) {
14
  const url = new URL(
15
    `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/sandbox`,
16
  );
17

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