Create a customer organization
Provisioning a tenant during onboarding
Clerk · Module
Creates a Clerk Organization through the backend SDK. Provide a name and optionally a creator, slug, membership limit, and metadata.
Call the backend organization's createOrganization method with the required name and optional creator, slug, membership limit, and metadata fields. It returns a promise resolving to the newly created Organization; the creator, when supplied, becomes an administrator.
function createOrganization(params: CreateParams): Promise<Organization>| Name | Type | Description |
|---|---|---|
name | string | The name of the Organization. |
createdBy? | string | The ID of the user creating the Organization; that user becomes an admin. |
maxAllowedMemberships? | number | Maximum memberships allowed; 0 means unlimited. |
privateMetadata? | OrganizationPrivateMetadata | Metadata readable and writable only through the Backend API. |
publicMetadata? | OrganizationPublicMetadata | Metadata readable through frontend and backend APIs, but writable only through the Backend API. |
slug? | string | The organization's slug. |
Promise<Organization>
const name = 'test-org'
const createdBy = 'user_123'
const organization = await clerkClient.organizations.createOrganization({ name, createdBy })
console.log(organization.id)Creates an organization through the backend Clerk client and logs the returned organization ID.
Provisioning a tenant during onboarding
Associating an initial administrator
Attaching server-controlled organization attributes
Controlling organization size
It is a backend SDK method with the signature createOrganization(params: CreateParams): Promise<Organization>. The required parameter is name; the result is a promise for the created Organization.
Follow-up: How would you make the creator an administrator? Pass the creator's user ID in createdBy; the documentation states that this user becomes an admin.
createdBy is an optional user ID identifying who creates the organization. That user becomes an administrator of the resulting organization.
Follow-up: What happens if no creator is supplied? The method can still create the organization, but no creator-based administrator assignment is specified by this page.
The method accepts optional privateMetadata and publicMetadata. Private metadata is readable and settable only through the Backend API, while public metadata can be read through frontend and backend APIs but set only through the Backend API.
Follow-up: How can membership capacity be configured? Supply maxAllowedMemberships; a value of 0 means unlimited memberships.
CreateParamsOrganizationclerkClientPOST /organizations