//native
type Pinterest = {
token: string;
};
/**
* Create a new asset group.
* Create a new asset group with the specified parameters.
- An asset group is a custom group of assets based on how you’d like to manage your accounts.
*/
export async function main(
auth: Pinterest,
business_id: string,
body: {
asset_group_name: string;
asset_group_description: string;
asset_group_types:
| "BRAND"
| "LOCATION_OR_LANGUAGE"
| "PRODUCT_LINE"
| "OTHER"[];
},
) {
const url = new URL(
`https://api.pinterest.com/v5/businesses/${business_id}/asset_groups`,
);
const response = await fetch(url, {
method: "POST",
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