āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/clerk/clerk-docs/reference/backend/invitations/create-invitation ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
createInvitation()'
description: Use Clerk's JS Backend SDK to create a new invitation for the given email address, and send the invitation email.
sdk: js-backend{/* clerk/javascript file: https://github.com/clerk/javascript/blob/main/packages/backend/src/api/endpoints/InvitationApi.ts#L42 */}
Creates a new Invitation for the given email address and sends the invitation email.
If an email address has already been invited or already exists in your application, trying to create a new invitation will return an error. To bypass this error and create a new invitation anyways, set ignoreExisting to true.
function createInvitation(params: CreateParams): Promise<Invitation>
CreateParamsThe email address of the user to invite.
redirectUrl?stringThe full URL or path where the user is redirected upon visiting the invitation link, where they can accept the invitation. Required if you have implemented a custom flow for handling application invitations.
publicMetadata?UserPublicMetadataMetadata that can be read from both the Frontend API and Backend API{{ target: '_blank' }}, but can be set only from the Backend API. Once the user accepts the invitation and signs up, these metadata will end up in the user's public metadata.
notify?booleanWhether an email invitation should be sent to the given email address. Defaults to true.
ignoreExisting?booleanWhether an invitation should be created if there is already an existing invitation for this email address, or if the email address already exists in the application. Defaults to false.
expiresInDays?numberThe number of days the invitation will be valid for. By default, the invitation expires after 30 days.
templateSlug?'invitation' | 'waitlist_invitation'The slug of the email template to use for the invitation email. Defaults to invitation.
</Properties>
const response = await clerkClient.invitations.createInvitation({
emailAddress: 'invite@example.com',
redirectUrl: 'https://www.example.com/my-sign-up',
publicMetadata: {
example: 'metadata',
example_nested: {
nested: 'metadata',
},
},
})
This method in the SDK is a wrapper around the BAPI endpoint POST/invitations. See the BAPI reference{{ target: '_blank' }} for more information.
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā