W012: Create organization
Creates a new tenant organization with the calling user as its owner. Triggered from the OrgSignup or NewOrganization page. Provisions the org row, the owner membership, and the default settings bundle in one transaction.
Steps
-
Create the organization row. Call
Platform.createOrganizationwith the requested name and a slug derived from the name. -
Make the caller the owner. Call
Platform.addMembership(userId, orgId, 'owner')for the user invoking the workflow. -
Seed the organization settings. Call
OrganizationSettings.upsertwith default values for currency, address placeholders, and branding fields.
Returns
The new organization plus the owner membership row.
Business rules
- Slug uniqueness across the platform. On collision, the workflow retries by appending a numeric suffix before giving up.
- Tenant context starts midway. The
createOrganizationline runs withoutapp.org_idset (the org doesn't exist yet). The settings step sets the GUC to the new org id so the tenant-scoped write succeeds.
Errors
ValidationError. Slug retries were exhausted, or the name failed shape checks at L4.