Instance Naming Convention
Format
PS-{number}-{suffix}
| Part | Description | Example |
|------|-------------|---------|
| PS | Pilot Status prefix | PS |
| {number} | Phone digits (normalized, no +) | 5511967435133 |
| {suffix} | Sequential counter per tenant+number+leg | 0, 1, 2… |
Examples
| Scenario | Primary (V2) | Secondary (GO) |
|----------|-------------|----------------|
| 1st instance | PS-5511967435133-0 | PS-5511967435133-0 |
| 2nd instance | PS-5511967435133-1 | PS-5511967435133-1 |
Rules
- Per-tenant scope: Each tenant's counter is independent. Two tenants can both have
PS-5511967435133-0. - Per-leg independence: Primary and secondary legs maintain separate counters. The same number can have N instances on each leg.
- Normalization: Leading zeros are stripped from the phone number before generating the name.
- Suffix calculation: Queries existing instances for the same tenant+number, extracts the max suffix from names matching
PS-{number}-{N}, then returnsmax + 1. First instance gets suffix0.
Previous Convention
Before standardization, names used random hex:
PS-{tenantId-prefix}-{random-hex} # e.g. PS-a1b2c3d4-f8e7d6c5
PS-GO-{tenantId-prefix}-{random-hex} # secondary GO
PS-V2-{tenantId-prefix}-{random-hex} # secondary V2
These were not human-readable and didn't encode the phone number.
Implementation
- Helper:
apps/fullstack/src/lib/whatsapp-instance-name.ts—generateInstanceName(tenantId, numberDigits) - Routes updated:
POST /api/whatsapp-instances— primary + secondaryPOST /api/v1/numbers— primary + secondaryPOST /api/whatsapp-instances/[id]/upgrade-to-dual— secondaryPOST /api/v1/numbers/[id]/upgrade-to-dual— secondary