Skip to content

Commit b6aa589

Browse files
authored
chore(backend): Allow to create organizations without initial owner (#4670)
1 parent a780f37 commit b6aa589

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.changeset/sharp-crabs-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/backend': minor
3+
---
4+
5+
Allow creating organizations without an initial owner to facilitate B2B onboarding flows

packages/backend/src/api/endpoints/OrganizationApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type CreateParams = {
3131
name: string;
3232
slug?: string;
3333
/* The User id for the user creating the organization. The user will become an administrator for the organization. */
34-
createdBy: string;
34+
createdBy?: string;
3535
maxAllowedMemberships?: number;
3636
} & MetadataParams;
3737

packages/backend/src/api/resources/JSON.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export interface OrganizationJSON extends ClerkResourceJSON {
157157
admin_delete_enabled: boolean;
158158
public_metadata: OrganizationPublicMetadata | null;
159159
private_metadata?: OrganizationPrivateMetadata;
160-
created_by: string;
160+
created_by?: string;
161161
created_at: number;
162162
updated_at: number;
163163
}

packages/backend/src/api/resources/Organization.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ export class Organization {
77
readonly slug: string | null,
88
readonly imageUrl: string,
99
readonly hasImage: boolean,
10-
readonly createdBy: string,
1110
readonly createdAt: number,
1211
readonly updatedAt: number,
1312
readonly publicMetadata: OrganizationPublicMetadata | null = {},
1413
readonly privateMetadata: OrganizationPrivateMetadata = {},
1514
readonly maxAllowedMemberships: number,
1615
readonly adminDeleteEnabled: boolean,
1716
readonly membersCount?: number,
17+
readonly createdBy?: string,
1818
) {}
1919

2020
static fromJSON(data: OrganizationJSON): Organization {
@@ -24,14 +24,14 @@ export class Organization {
2424
data.slug,
2525
data.image_url || '',
2626
data.has_image,
27-
data.created_by,
2827
data.created_at,
2928
data.updated_at,
3029
data.public_metadata,
3130
data.private_metadata,
3231
data.max_allowed_memberships,
3332
data.admin_delete_enabled,
3433
data.members_count,
34+
data.created_by,
3535
);
3636
}
3737
}

0 commit comments

Comments
 (0)