updateOrganizationMembership()
Updates a user's OrganizationMembership
. Currently, only the role can be updated.
function updateOrganizationMembership: (params: UpdateOrganizationMembershipParams) => Promise<OrganizationMembership>;
- Name
organizationId
- Type
string
- Description
The organization ID of the organization a user belongs to.
- Name
userId
- Type
string
- Description
The ID of the user.
- Name
role
- Type
string
- Description
The role to assign user.
Example
In the following example, you can see that the returned OrganizationMembership
object has its role
property updated to org:admin
.
const organizationId = 'org_123';
const userId = 'user_123';
const role = 'org:admin';
const response = await clerkClient.organizations.updateOrganizationMembership({organizationId, userId, role});
console.log(response);
/*
_OrganizationMembership {
id: 'orgmem_123',
role: 'org:admin',
publicMetadata: {},
privateMetadata: {},
createdAt: 1702488558867,
updatedAt: 1705535333002,
organization: _Organization {
id: 'org_123',
name: 'Test Org',
slug: 'test-org',
imageUrl: 'https://img.clerk.com/eyJ...',
hasImage: false,
createdBy: 'user_123',
createdAt: 1702488558853,
updatedAt: 1705534260298,
publicMetadata: {},
privateMetadata: {},
maxAllowedMemberships: 3,
adminDeleteEnabled: true,
members_count: undefined
},
publicUserData: _OrganizationMembershipPublicUserData {
identifier: 'alexis@clerk.dev',
firstName: 'Alexis',
lastName: 'Aguilar',
imageUrl: 'https://img.clerk.com/eyJ...',
hasImage: true,
userId: 'user_123'
}
}
*/
Backend API (BAPI) endpoint
This method in the SDK is a wrapper around the BAPI endpoint PATCH/organizations/{organization_id}/memberships/{user_id}
. See the BAPI reference for more details.