//native
type Pinterest = {
token: string;
};
/**
* Update audience sharing from a business to ad accounts
* From a business, share a specific audience with other ad account(s), or revoke access to a previously shared audience. If the business is the owner of the audience, it can share with any ad account within the same business hierarchy. If the business is the recipient of the audience, it can share with any of its owned ad accounts. This endpoint is not available to all apps.Learn more.
*/
export async function main(
auth: Pinterest,
business_id: string,
body: { audience_id?: string; operation_type?: "SHARE" | "REVOKE" } & {
recipient_account_ids: string[];
},
) {
const url = new URL(
`https://api.pinterest.com/v5/businesses/${business_id}/audiences/ad_accounts/shared`,
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 536 days ago