0

Edit insertion order through SSIO.

by
Published Dec 20, 2024

Edit insertion order through SSIO for ad_account_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
 * Edit insertion order through SSIO.
7
 * Edit insertion order through SSIO for ad_account_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
  body: {
14
    start_date?: string;
15
    end_date?: string;
16
    po_number?: string;
17
    budget_amount?: number;
18
    billing_contact_firstname?: string;
19
    billing_contact_lastname?: string;
20
    billing_contact_email?: string;
21
    media_contact_firstname?: string;
22
    media_contact_lastname?: string;
23
    media_contact_email?: string;
24
    agency_link?: string;
25
    user_email?: string;
26
  } & {
27
    oracle_line_id?: string;
28
    salesforce_order_id?: string;
29
    salesforce_order_line_id?: string;
30
    ads_manager_order_line_id?: string;
31
  },
32
) {
33
  const url = new URL(
34
    `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/ssio/insertion_orders`,
35
  );
36

37
  const response = await fetch(url, {
38
    method: "PATCH",
39
    headers: {
40
      "Content-Type": "application/json",
41
      Authorization: "Bearer " + auth.token,
42
    },
43
    body: JSON.stringify(body),
44
  });
45
  if (!response.ok) {
46
    const text = await response.text();
47
    throw new Error(`${response.status} ${text}`);
48
  }
49
  return await response.json();
50
}
51