Back to Playbook
Act 1: First Contact

3. Behind the Scenes: Provisioning

Story

Sarah submitted the trial form. She doesn't see it, but several things happen in a single coordinated transaction to get her company ready.

Happy Path

The system creates everything in one atomic transaction:

  1. 1Company record — name, address, status set to ACTIVE, environment set to CUSTOMER
  2. 2Tenant — a multi-tenant abstraction linked to the company
  3. 3Roles — default roles created: OWNER, COMPANY_ADMIN, HRMANAGER, PAYROLLMANAGER, EMPLOYEE
  4. 4Permissions — each role gets granular defaults (module + action + resource level)
  5. 5Subscription — a CompanySubscription with status TRIALING and an end date
  6. 6User record — Sarah's account created (or linked if she exists), with the OWNER role
  7. 7Trial record — logged for deduplication and analytics
  8. 8OTP email queued — an invitation OTP is prepared for delivery

All or nothing. If any step fails, everything rolls back. No orphan records, no half-setup companies.

Failure Modes

FailureWhat the user seesWhat happens next
Any step fails mid-transactionGeneric error, no company createdFull rollback, user retries
User already exists in the systemAssigned to the new company with OWNER roleNo duplicate user, proceed normally
Company name matches existing (different domain)Allowed — no conflictCompanies are isolated by tenant
User exists but email not verifiedMust verify email before accessing the dashboardSame OTP verification flow applies
Trial expired and user wants anotherDepends on policy — typically rejectedContact support for extension

Edge Cases

ScenarioBehaviorWhy
Same company name, different domainAllowedCompany names are not globally unique
User signed up before but never completed OTPNew invite sent, old one invalidatedFresh start for the new trial
Provisioning modes differSelf-serve: status ACTIVE with trial. Admin-provisioned: status LOCKEDDifferent trust levels for different entry points

ZettaHRM

A modern HRM workspace for employee management, attendance tracking, leave approvals and structured day-to-day HR operations.

© 2026 Zettabyte Technology Inc.|All rights reserved.