//native
type Klaviyo = {
apiKey: string;
};
/**
* Create Tag Group
* Create a tag group. An account cannot have more than **50** unique tag groups.
If `exclusive` is not specified `true` or `false`, the tag group defaults to non-exclusive.
If a tag group is non-exclusive, any given related resource (campaign, flow, etc.)
can be linked to multiple tags from that tag group.
If a tag group is exclusive, any given related resource can only be linked to one tag from that tag group.*Rate limits*:Burst: `3/s`Steady: `60/m`
*/
export async function main(
auth: Klaviyo,
revision: string,
body: {
data: {
type: "tag-group";
attributes: { name: string; exclusive?: false | true };
};
},
) {
const url = new URL(`https://a.klaviyo.com/api/tag-groups`);
const response = await fetch(url, {
method: "POST",
headers: {
revision: revision,
"Accept": "application/vnd.api+json",
"Content-Type": "application/vnd.api+json",
Authorization: "Klaviyo-API-Key " + auth.apiKey,
},
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 428 days ago