//native
type Klaviyo = {
apiKey: string;
};
/**
* Request Profile Deletion
* Request a deletion for the profiles corresponding to one of the following identifiers: `email`, `phone_number`, or `id`.
*/
export async function main(
auth: Klaviyo,
revision: string,
body: {
data: {
type: "data-privacy-deletion-job";
attributes: {
profile: {
data: {
type: "profile";
id?: string;
attributes: { email?: string; phone_number?: string };
};
};
};
};
},
) {
const url = new URL(`https://a.klaviyo.com/api/data-privacy-deletion-jobs`);
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