//native
type Clerk = {
apiKey: string;
};
/**
* Create multiple invitations
* Use this API operation to create multiple invitations for the provided email addresses. You can choose to send the
invitations as emails by setting the `notify` parameter to `true`. There cannot be an existing invitation for any
of the email addresses you provide unless you set `ignore_existing` to `true` for specific email addresses. Please
note that there must be no existing user for any of the email addresses you provide, and this rule cannot be bypassed.
*/
export async function main(
auth: Clerk,
body: {
email_address: string;
public_metadata?: {};
redirect_url?: string;
notify?: false | true;
ignore_existing?: false | true;
expires_in_days?: number;
}[],
) {
const url = new URL(`https://api.clerk.com/v1/invitations/bulk`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + 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