Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.dev

Invitations

Learn how to invite users to your application

Overview

Clerk makes it easy to invite users to your application via the invitations feature. This feature is offered by default to all Clerk applications without any extra configuration.

All that is needed to do is to create an invitation for an email address. Once the invitation is created, an email with an invitation link will be sent to the user's email address. By clicking on the invitation link, the user will be redirected to the application's sign up page and their email address will have been automatically verified. At this point, the user will just have to fill in the rest of the details according to the application's settings.

Invitations expire after a month. If the user clicks on an expired invitation, they will get redirected to the application's sign-up page but they will still have to go via the normal sign-up flow, i.e. their email address will not be auto-verified.

Invitations are only used to invite users to your application. The application will still be available to everyone even without an invitation.If you're looking into creating invitation-only applications, please refer to our allowlist feature.

Before you start

Creating invitations

At the moment, you can only create invitations for email addresses via the Backend API. First, you will need to grab your API key which can be found in Clerk Dashboard under API Keys > Backend API Keys.

Once you have that, you can make the following request to the Backend API:

This will create a new invitation and send an invitation email to the given email address.

Revoking invitations

Revoking an invitation prevents the user from using the invitation link that was sent to them. In order to revoke an invitation, you can make the following request to the Backend API:

The invitation id can be found in the response of the invitation creation request.

Revoking an invitation does not prevent the user from signing up on their own.If you're looking for invitation-only applications, please refer to our allowlist feature.

Invitation metadata

Invitations can optionally carry metadata that will eventually end up in the created user once they sign up. The metadata must be a well-formed JSON object.

In order to add metadata to an invitation, you can use the public_metadata property when the invitation is created:

Once an invited user signs up using the invitation link, the invitation metadata will end up in the user's public_metadata. For more information on a user's metadata, please refer to Custom User Metadata.

Custom flow

If you're using Clerk Hosted Pages or Clerk Components, invitation links are handled out of the box. However, if you have built custom sign up and sign in flows using ClerkJS directly, then you'll need to do a little bit of extra work.

The first thing that changes in this case is that during the invitation creation, you will need to specify the url of your sign up page. You can do that by including an additional redirect_url parameter in the invitation creation request.

This redirect_url basically tells Clerk where to redirect the user when they click on the invitation link. This redirection will include an invitation token, something like the following:

The second and final thing you'll need to do is to pass this token into the sign up create call, when starting the sign up flow.

1
1

Was this helpful?

Clerk © 2022