Começar Agora

Multi-Tenancy Overview

SaasKitFy uses organization-based multi-tenancy. Every organization has its own members, roles, billing plan, and resources — fully isolated from other tenants.

Two Tenant Modes

  • Organization mode (B2B): Users create and join multiple organizations. An org switcher lets them move between workspaces.
  • Personal mode (B2C): Each user gets a single auto-created workspace. The org layer is invisible to the end user.

The mode is set in config/saas.php via the tenant_mode key and can be changed at runtime through the admin panel.

Data Isolation

The SetActiveOrganization middleware resolves the current tenant from the X-Organization-Id header (or session). Once set, all org-scoped queries automatically filter by organization_id.

# Every API request includes the active org
X-Organization-Id: org_abc123

Key Models

  • Organization — the tenant itself (name, slug, billing, settings)
  • OrganizationUser — pivot table linking users to orgs, with a role column
  • OrgRoleTemplate — customizable role definitions with JSON permissions

Organization Relationships

Each Organization model has the following relationships:

  • members — users belonging to the org
  • owner — the user who owns the org
  • invitations — pending invites sent to email addresses
  • apiKeys — programmatic API keys scoped to the org
  • samlConfiguration — SSO/SAML settings for enterprise customers
  • domains — verified domains associated with the org
  • subscriptions — Stripe subscriptions via Laravel Cashier