Skip to main content

createOrganizationInvitation()

Caution

This endpoint is rate limited to 250 requests per hour per application instance.

Creates an invitation for a user to join an Organization.

Returns the newly created OrganizationInvitation object.

function createOrganizationInvitation(params: CreateOrganizationInvitationParams): Promise<OrganizationInvitation>
  • Name
    emailAddress
    Type
    string
    Description

    The email address of the user being invited.

  • Name
    expiresInDays?
    Type
    number
    Description

    The number of days until the invitation expires. Defaults to 30.

  • Name
    inviterUserId?
    Type
    string
    Description

    The ID of the user creating the invitation.

  • Name
    organizationId
    Type
    string
    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?
    Type
    string
    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.

Note

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.

Feedback

What did you think of this content?

Last updated on