0

Get lead form by id

by
Published Dec 20, 2024

This feature is currently in beta and not available to all apps, if you're interested in joining the beta, please reach out to your Pinterest account manager. Gets a lead form given it's ID. It must also be associated with the provided ad account ID. For more, see Lead ads.

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 lead form by id
7
 * This feature is currently in beta and not available to all apps, if you're interested in joining the beta, please reach out to your Pinterest account manager.
8

9
Gets a lead form given it's ID. It must also be associated with the provided ad account ID.
10

11
For more, see Lead ads.
12
 */
13
export async function main(
14
  auth: Pinterest,
15
  ad_account_id: string,
16
  lead_form_id: string,
17
) {
18
  const url = new URL(
19
    `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/lead_forms/${lead_form_id}`,
20
  );
21

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