Skip to Content
You are viewing a beta version of Clerk Docs
Visit the latest docs
Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.com

createOrganization()

Creates an Organization.

function createOrganization: (params: CreateParams) => Promise<Organization>;

CreateParams

NameTypeDescription
namestringName of the organization.
createdBystringThe user ID for the user creating the organization. The user will become an administrator for the organization.
slug?stringSlug of the organization.
publicMetadata?Record<string, unknown>Metadata saved on the organization, that is visible to both your Frontend and Backend APIs.
privateMetadata?Record<string, unknown>Metadata saved on the organization that is only visible to your Backend API.

createOrganization() example

const name = 'test-org'; const createdBy = 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56'; const response = await clerkClient.organizations.createOrganization({ name, createdBy }); console.log(response); /* _Organization { id: 'org_2b6TtF4XlxDsKo6t0E0UyywGB72', name: 'test-org', slug: 'test-org-1705534741', imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoiZGVmYXVsdCIsImlpZCI6Imluc18yVjdKRFdyclJwRmZFZTlqQUM2dWpSMG8xSlQiLCJyaWQiOiJvcmdfMmI2VHRGNFhseERzS282dDBFMFV5eXdHQjcyIiwiaW5pdGlhbHMiOiJUIn0', hasImage: false, createdBy: 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56', 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(opens in a new tab) for more details.

Last updated on January 8, 2024

What did you think of this content?

Clerk © 2024