0

Get ad

by
Published Dec 20, 2024

Get a specific ad given the ad ID. If your pin is rejected, rejected_reasons will contain additional information from the Ad Review process. For more information about our policies and rejection reasons see the Pinterest advertising standards.

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 ad
7
 * Get a specific ad given the ad ID. If your pin is rejected, rejected_reasons will
8
contain additional information from the Ad Review process.
9
For more information about our policies and rejection reasons see the Pinterest advertising standards.
10
 */
11
export async function main(
12
  auth: Pinterest,
13
  ad_account_id: string,
14
  ad_id: string,
15
) {
16
  const url = new URL(
17
    `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/ads/${ad_id}`,
18
  );
19

20
  const response = await fetch(url, {
21
    method: "GET",
22
    headers: {
23
      Authorization: "Bearer " + auth.token,
24
    },
25
    body: undefined,
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