0

Get insertion order status by pin order id.

by
Published Dec 20, 2024

Get insertion order status for pin order id pin_order_id. - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Finance, Campaign.

Script pinterest Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Pinterest = {
3
  token: string;
4
};
5
/**
6
 * Get insertion order status by pin order id.
7
 * Get insertion order status for pin order id pin_order_id.
8
- The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Finance, Campaign.
9
 */
10
export async function main(
11
  auth: Pinterest,
12
  ad_account_id: string,
13
  pin_order_id: string,
14
) {
15
  const url = new URL(
16
    `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/ssio/insertion_orders/${pin_order_id}/status`,
17
  );
18

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