//native
type Shutterstock = {
token: string;
};
/**
* Create catalog collections
* This endpoint creates a catalog collection and optionally adds assets. To add assets to the collection later, use `PATCH /v2/catalog/collections/{collection_id}/items`.
*/
export async function main(
auth: Shutterstock,
body: {
name: string;
visibility?: "private" | "public";
items?: { asset: { id?: string; type: string } }[];
},
) {
const url = new URL(`https://api.shutterstock.com/v2/catalog/collections`);
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 235 days ago