//native
type Klaviyo = {
apiKey: string;
};
/**
* Refresh Campaign Recipient Estimation
* Trigger an asynchronous job to update the estimated number of recipients
for the given campaign ID. Use the `Get Campaign Recipient Estimation
Job` endpoint to retrieve the status of this estimation job. Use the
`Get Campaign Recipient Estimation` endpoint to retrieve the estimated
recipient count for a given campaign.*Rate limits*:Burst: `10/s`Steady: `150/m`
*/
export async function main(
auth: Klaviyo,
revision: string,
body: { data: { type: "campaign-recipient-estimation-job"; id: string } },
) {
const url = new URL(
`https://a.klaviyo.com/api/campaign-recipient-estimation-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