createOrganizationInvitation() - Organizations | Clerk Docs
createOrganizationInvitation()
Creates an invitation for a user to join an Organization.
Returns the newly created OrganizationInvitation object.
function createOrganizationInvitation(params: CreateOrganizationInvitationParams): Promise<OrganizationInvitation>
CreateOrganizationInvitationParams
Name
emailAddress
Typestring
Description
The email address of the user being invited.Name
expiresInDays?
Typenumber
Description
The number of days until the invitation expires. Defaults to30.Name
inviterUserId?
Typestring
Description
The ID of the user creating the invitation.Name
organizationId
Typestring
Description
The ID of the Organization the user is being invited to.Name
privateMetadata?
Type OrganizationInvitationPrivateMetadata
Description
Metadata that can be read and set only from the Backend API.Name
publicMetadata?
Type OrganizationInvitationPublicMetadata
Description
Metadata that can be read from the Frontend API and Backend API, but can be set only from the Backend API.Name
redirectUrl?
Typestring
Description
The full URL or path where the user will land after accepting the invitation.Name
role
Type OrganizationCustomRoleKey
Description
The Role to assign to the user.
Usage
Using clerkClient varies based on the SDK you're using. Refer to the overview for usage details, including guidance on how to access the userId and other properties.
const organizationId = 'org_123'
const inviterUserId = 'user_123'
const emailAddress = 'testclerk123@clerk.dev'
const role = 'org:member'
const response = await clerkClient.organizations.createOrganizationInvitation({
organizationId,
inviterUserId,
emailAddress,
role,
})
Backend API (BAPI) endpoint
This method in the SDK is a wrapper around the BAPI endpoint POST/organizations/{organization_id}/invitations. See the BAPI reference for more information.