//native
type Pinterest = {
token: string;
};
/**
* Update audience sharing between businesses
* From a business, share a specific audience with another business account, or revoke access to a previously shared audience. Only the audience owner can share the audience with other businesses, and the recipient business must be within the same business hierarchy. 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_business_ids: string[];
},
) {
const url = new URL(
`https://api.pinterest.com/v5/businesses/${business_id}/audiences/businesses/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