Edits history of script submission #11244 for ' Delete lead ads subscription (pinterest)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Pinterest = {
      token: string;
    };
    /**
     * Delete lead ads subscription
     * Delete an existing lead ads webhook subscription by ID.
    - Only requests for the OWNER or ADMIN of the ad_account will be allowed.
    
    This endpoint is currently in beta and not available to all apps. Learn more.
     */
    export async function main(
      auth: Pinterest,
      ad_account_id: string,
      subscription_id: string,
    ) {
      const url = new URL(
        `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/leads/subscriptions/${subscription_id}`,
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 536 days ago