Docs

deleteOrganizationMembership()

Removes a user from the specified organization.

function getOrganizationList(
  params: DeleteOrganizationMembershipParams,
): Promise<OrganizationMembership>
  • Name
    organizationId
    Type
    string
    Description

    The ID of the organization the user will be removed from.

  • Name
    userId
    Type
    string
    Description

    The ID of the user to be removed from the organization.

const organizationId = 'org_123'

const userId = 'user_123'

const response = await clerkClient.organizations.deleteOrganizationMembership({
  organizationId,
  userId,
})

console.log(response)
/*
_OrganizationMembership {
  id: 'orgmem_123',
  role: 'org:member',
  publicMetadata: {},
  privateMetadata: {},
  createdAt: 1705534546701,
  updatedAt: 1705534546701,
  organization: _Organization {
    id: 'org_123',
    name: 'Test Org',
    slug: 'test-org',
    imageUrl: 'https://img.clerk.com/eyJ...',
    hasImage: false,
    createdBy: 'user_456',
    createdAt: 1702488558853,
    updatedAt: 1705536790529,
    publicMetadata: [Object],
    privateMetadata: {},
    maxAllowedMemberships: 3,
    adminDeleteEnabled: true,
    members_count: undefined
  },
  publicUserData: _OrganizationMembershipPublicUserData {
    identifier: 'testclerk123@gmail.com',
    firstName: 'Test',
    lastName: 'Clerk',
    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 DELETE/organizations/{organization_id}/memberships/{user_id}. See the BAPI reference for more information.

Feedback

What did you think of this content?

Last updated on