Organizations

Organizations are the core tenant unit. Each org has its own members, billing, settings, and resources.

API Routes

GET    /api/organizations              # list user's orgs
POST   /api/organizations              # create a new org
GET    /api/organizations/{id}         # show org details
PUT    /api/organizations/{id}         # update org
DELETE /api/organizations/{id}         # delete org
POST   /api/organizations/{id}/switch  # switch active org

Creating an Organization

POST /api/organizations
{
    "name": "Acme Inc."
}
  • A URL-safe slug is auto-generated from the name
  • The authenticated user is automatically assigned the owner role
  • A default subscription or trial is attached based on your billing config

Organization Model

Key fields on the Organization model:

  • name — display name
  • slug — auto-generated, URL-safe identifier
  • avatar — optional org avatar/logo path
  • owner_id — foreign key to the owning user
  • mfa_required — boolean, enforces MFA for all org members
  • credit_balance — prepaid credit balance for usage-based billing

Stripe Integration

The Organization model uses Laravel Cashier's Billable trait, so billing is handled at the org level — not the user level.

use Laravel\Cashier\Billable;

class Organization extends Model
{
    use Billable;
}

Switching Organizations

POST /api/organizations/{id}/switch

Sets the active organization for the current session. Subsequent requests will use this org as the tenant context. The frontend typically sends the X-Organization-Id header on every request.