createOrganizationMembership()
Creates a membership to an organization for a user directly (circumventing the need for an invitation). Returns a OrganizationMembership
object.
function createOrganizationMembership(
params: CreateOrganizationMembershipParams,
): Promise<OrganizationMembership>
- Name
organizationId
- Type
string
- Description
The ID of the organization the user is being added to.
- Name
userId
- Type
string
- Description
The ID of the user to be added to the organization.
- Name
role
- Type
string
- Description
The role to assign the added user within the organization.
In the following example, an OrganizationMembership
is created for a user with the role org:member
.
const organizationId = 'org_123'
const userId = 'user_123'
const role = 'org:member'
const response = await clerkClient.organizations.createOrganizationMembership({
organizationId,
userId,
role,
})
Backend API (BAPI) endpoint
This method in the SDK is a wrapper around the BAPI endpoint POST/organizations/{organization_id}/memberships
. See the BAPI reference for more information.
Feedback
Last updated on