[ 01 ]—Software
API Design for SaaS: Tenancy, Auth, and Versioning
SaaS APIs fail quietly when tenancy, auth, and versioning are treated as afterthoughts. OnesDev designs those boundaries early — so Laravel or Node products can grow without rewriting every client.
Pick a tenancy model on purpose
Most B2B products start with shared-database, row-level tenancy (tenant_id on every table). It is cheaper to operate and fine until compliance or noisy neighbors force isolation. Dedicated schemas or databases come later — when a customer contract or data residency rule requires them. The mistake is mixing models without documenting which resources are shared.
Decide before the first schema migrate
- Who owns the data: org, workspace, or user?
- Can a user belong to multiple tenants?
- Do background jobs inherit tenant context?
- What must never leak across tenant boundaries?
Auth that matches the product
Session cookies work for first-party portals. Machine-to-machine needs short-lived tokens and scoped permissions. Role checks belong next to the domain action (policy / guard), not scattered as string compares in controllers. We also log authz denials with enough context to debug — without dumping secrets into logs.
Versioning without ceremony
Prefer additive change: new fields optional, old fields deprecated with a sunset date. Path versioning (/v1, /v2) is clearer for breaking changes than header gymnastics for small teams. Document what is stable, what is beta, and what clients must not cache forever.
Idempotency and webhooks
Payments, invites, and provisioning endpoints need idempotency keys. Outbound webhooks need retries with backoff and signature verification. These two habits prevent most “it charged twice” support tickets.
Next step
See how we approach software development, or share your tenancy and auth constraints — we will propose an API shape that matches how you sell and operate.
OnesDev Engineering Team
Full-Stack & Cloud PracticeEngineers building and operating production Laravel, MERN, WordPress, and AWS cloud systems worldwide.
✓ AWS Certified Architects & Senior Full-Stack Engineers
[ 02 ]—Related