Invite users to your application
Inviting users to your Clerk application allows you to onboard new users seamlessly by sending them a unique invitation link.
Once you create an invitation, Clerk sends an email to the invited user with a unique invitation link. When the user visits the invitation link, they will be redirected to the Account Portal sign-up page and their email address will be automatically verified. If you want to redirect the user to a specific page in your application, you can specify a redirect URL when creating the invitation.
Invitations expire after a month. If the user clicks on an expired invitation, they will get redirected to the application's sign-up page and will have to go through the normal sign-up flow. Their email address will not be auto-verified.
Create an invitation
You can create an invitation in the Clerk Dashboard or using the Backend API.
Using Clerk Dashboard
To invite users, navigate to the Users page from the top-level menu, then select the Invitations tab. Select Invite user and enter the email address of the person you want to invite. Optionally, set an expiration date for the invitation. Once you've entered the necessary details, click Send invite to send the invitation email.
Using Backend API
You can either use a cURL command or the JavaScript Backend SDK to create an invitation. Clerk's JavaScript Backend SDK is a wrapper around the Backend API that makes it easier to interact with the API. Use the following tabs to see examples for each method.
The following example demonstrates how to create an invitation using cURL.
Replace the email address with the email address you want to invite. Your Clerk Secret Key is already injected into the code snippet.
Replace the email address with the email address you want to invite. Update YOUR_SECRET_KEY
with your Clerk Secret Key which can be found on the API keys page in the Clerk Dashboard.
To use the Backend SDK to create an invitation, see the createInvitation()
reference.
See the Backend API reference for an example of the response.
Redirect URL
When you create an invitation, you can specify a redirect_url
parameter. This parameter tells Clerk where to redirect the user when they visit the invitation link.
The following example demonstrates how to use cURL to create an invitation with the redirect_url
set to https://www.example.com/accept-invitation
:
Once the user visits the invitation link, they will be redirected to the page you specified, which means you must handle the sign-up flow in your code for that page. You can either embed the <SignUp />
component on that page, or if the prebuilt component doesn't meet your specific needs or if you require more control over the logic, you can build a custom flow.
Invitation metadata
You can also add metadata to an invitation. Once the invited user signs up using the invitation link, the invitation metadata will end up in the user's public_metadata
. You can find more information about user metadata in the metadata docs.
To add metadata to an invitation, you can use the public_metadata
property when the invitation is created.
The following example demonstrates how to create an invitation with metadata using cURL.
Replace the email address with the email address you want to invite, and the public_metadata
with the metadata you want to add. Your Secret Key is already injected into the code snippet.
Replace the email address with the email address you want to invite, and the public_metadata
with the metadata you want to add. Update YOUR_SECRET_KEY
with your Clerk Secret Key which can be found on the API keys page in the Clerk Dashboard.
Revoking invitations
You can revoke an invitation at any time. Revoking an invitation prevents the user from using the invitation link that was sent to them.
Using Clerk Dashboard
To revoke an invitation, navigate to the Users page from the top-level menu, then select the Invitations tab. Find the invitation you want to revoke and select Revoke from the dropdown menu on the right.
Using Backend API
You can either use a cURL command or the JavaScript Backend SDK to create an invitation. Use the following tabs to see examples for each method.
The following example demonstrates how to revoke an invitation using cURL.
Replace the <invitation_id>
with the ID of the invitation you want to revoke. Your Secret Key is already injected into the code snippet.
Replace the <invitation_id>
with the ID of the invitation you want to revoke and replace YOUR_SECRET_KEY
with your Clerk Secret Key. You can find your Secret Key on the API keys page in the Clerk Dashboard.
To use the Backend SDK to revoke an invitation, see the revokeInvitation()
reference documentation.
See the Backend API reference for an example of the response.
Custom flow
Clerk's prebuilt components and Account Portal pages handle the sign-up flow for you, including the invitation flow. If you want to build a custom sign-up flow, see the custom flow guide.
Feedback
Last updated on