Skip to main content
Version: v1.0.0(int)

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

  1. Create the organization row. Call Platform.createOrganization with the requested name and a slug derived from the name.

  2. Make the caller the owner. Call Platform.addMembership(userId, orgId, 'owner') for the user invoking the workflow.

  3. Seed the organization settings. Call OrganizationSettings.upsert with 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 createOrganization line runs without app.org_id set (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.