Docs

createOrganization()

Creates an Organization.

function createOrganization(params: CreateParams): Promise<Organization>
  • Name
    name
    Type
    string
    Description

    Name of the organization.

  • Name
    createdBy
    Type
    string
    Description

    The user ID for the user creating the organization. The user will become an administrator for the organization.

  • Name
    slug?
    Type
    string
    Description

    Slug of the organization.

  • Name
    publicMetadata?
    Type
    OrganizationPublicMetadata
    Description

    Metadata that can be read from both the Frontend API and Backend API, but can be set only from the Backend API.

  • Name
    privateMetadata?
    Type
    OrganizationPrivateMetadata
    Description

    Metadata that is only visible to your Backend API.

  • Name
    maxAllowedMemberships?
    Type
    number
    Description

    The maximum number of memberships allowed in the organization.

const name = 'test-org'

const createdBy = 'user_123'

const response = await clerkClient.organizations.createOrganization({ name, createdBy })

console.log(response)
/*
_Organization {
  id: 'org_123',
  name: 'test-org',
  slug: 'test-org-1705534741',
  imageUrl: 'https://img.clerk.com/eyJ...',
  hasImage: false,
  createdBy: 'user_123',
  createdAt: 1705534741971,
  updatedAt: 1705534741971,
  publicMetadata: {},
  privateMetadata: {},
  maxAllowedMemberships: 3,
  adminDeleteEnabled: true,
  members_count: undefined
}
*/

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint POST/organizations. See the BAPI reference for more information.

Feedback

What did you think of this content?

Last updated on