0

Delete partner access to asset

by
Published Dec 20, 2024

Terminate multiple partners' access to an asset. If - partner_type=INTERNAL: You will terminate a partner's asset access to your business assets. - partner_type=EXTERNAL: You will terminate your own access to your partner's business assets.

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 partner access to asset
7
 * Terminate multiple partners' access to an asset. If
8
- partner_type=INTERNAL: You will terminate a partner's asset access to your business assets.
9
- partner_type=EXTERNAL: You will terminate your own access to your partner's business assets.
10
 */
11
export async function main(
12
  auth: Pinterest,
13
  business_id: string,
14
  body: {
15
    accesses: {
16
      partner_id: string;
17
      asset_id: string;
18
      partner_type?: "INTERNAL" | "EXTERNAL";
19
    }[];
20
  },
21
) {
22
  const url = new URL(
23
    `https://api.pinterest.com/v5/businesses/${business_id}/partners/assets`,
24
  );
25

26
  const response = await fetch(url, {
27
    method: "DELETE",
28
    headers: {
29
      "Content-Type": "application/json",
30
      Authorization: "Bearer " + auth.token,
31
    },
32
    body: JSON.stringify(body),
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.json();
39
}
40