0

Terminate business partnerships

by
Published Dec 20, 2024

Terminate partnerships between the specified partners and your business. Note: You may only batch terminate partners of the same partner type.

Script pinterest Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Pinterest = {
3
  token: string;
4
};
5
/**
6
 * Terminate business partnerships
7
 * Terminate partnerships between the specified partners and your business.
8
Note: You may only batch terminate partners of the same partner type.
9
 */
10
export async function main(
11
  auth: Pinterest,
12
  business_id: string,
13
  body: { partner_ids: string[]; partner_type?: "INTERNAL" | "EXTERNAL" },
14
) {
15
  const url = new URL(
16
    `https://api.pinterest.com/v5/businesses/${business_id}/partners`,
17
  );
18

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