diff --git a/.changeset/sharp-crabs-wave.md b/.changeset/sharp-crabs-wave.md new file mode 100644 index 0000000000..8bc8edbda6 --- /dev/null +++ b/.changeset/sharp-crabs-wave.md @@ -0,0 +1,5 @@ +--- +'@clerk/backend': minor +--- + +Allow creating organizations without an initial owner to facilitate B2B onboarding flows diff --git a/packages/backend/src/api/endpoints/OrganizationApi.ts b/packages/backend/src/api/endpoints/OrganizationApi.ts index 01d608c027..e2164fec96 100644 --- a/packages/backend/src/api/endpoints/OrganizationApi.ts +++ b/packages/backend/src/api/endpoints/OrganizationApi.ts @@ -31,7 +31,7 @@ type CreateParams = { name: string; slug?: string; /* The User id for the user creating the organization. The user will become an administrator for the organization. */ - createdBy: string; + createdBy?: string; maxAllowedMemberships?: number; } & MetadataParams; diff --git a/packages/backend/src/api/resources/JSON.ts b/packages/backend/src/api/resources/JSON.ts index a333d17e02..a3aed38e3b 100644 --- a/packages/backend/src/api/resources/JSON.ts +++ b/packages/backend/src/api/resources/JSON.ts @@ -157,7 +157,7 @@ export interface OrganizationJSON extends ClerkResourceJSON { admin_delete_enabled: boolean; public_metadata: OrganizationPublicMetadata | null; private_metadata?: OrganizationPrivateMetadata; - created_by: string; + created_by?: string; created_at: number; updated_at: number; } diff --git a/packages/backend/src/api/resources/Organization.ts b/packages/backend/src/api/resources/Organization.ts index ab88fd9025..840942e51a 100644 --- a/packages/backend/src/api/resources/Organization.ts +++ b/packages/backend/src/api/resources/Organization.ts @@ -7,7 +7,6 @@ export class Organization { readonly slug: string | null, readonly imageUrl: string, readonly hasImage: boolean, - readonly createdBy: string, readonly createdAt: number, readonly updatedAt: number, readonly publicMetadata: OrganizationPublicMetadata | null = {}, @@ -15,6 +14,7 @@ export class Organization { readonly maxAllowedMemberships: number, readonly adminDeleteEnabled: boolean, readonly membersCount?: number, + readonly createdBy?: string, ) {} static fromJSON(data: OrganizationJSON): Organization { @@ -24,7 +24,6 @@ export class Organization { data.slug, data.image_url || '', data.has_image, - data.created_by, data.created_at, data.updated_at, data.public_metadata, @@ -32,6 +31,7 @@ export class Organization { data.max_allowed_memberships, data.admin_delete_enabled, data.members_count, + data.created_by, ); } }