Invite Codes
Invite codes gate access to the org setup wizard. Only users with a valid code can create a new organization.
Schema
| Column | Type | Description |
|---|---|---|
id | UUID | Primary key |
code | TEXT | Unique invite code string |
max_uses | INT | Maximum allowed uses (NULL = unlimited) |
times_used | INT | Current usage count |
expires_at | TIMESTAMPTZ | Optional expiration |
created_at | TIMESTAMPTZ | Creation timestamp |
Validation Rules
An invite code is valid when:
- The code exists in the database
times_used < max_uses(ormax_usesis NULL)expires_atis NULL or in the future
Usage Flow
- User enters code on the setup wizard
- Backend validates the code via
GetInviteCodeByCodequery - If valid,
times_usedis incremented - A setup JWT is issued containing the
invite_code_id - All subsequent wizard steps use this JWT for authentication
Creating Invite Codes
Currently, invite codes are managed directly in the database:
-- Create an invite code with 100 max uses
INSERT INTO invite_codes (code, max_uses)
VALUES ('WELCOME-2024', 100);
-- Create an unlimited invite code
INSERT INTO invite_codes (code)
VALUES ('UNLIMITED-DEV');
-- Create a code that expires
INSERT INTO invite_codes (code, max_uses, expires_at)
VALUES ('PROMO-Q1', 50, '2025-03-31T23:59:59Z');Development
For local development, seed a test invite code:
INSERT INTO invite_codes (code, max_uses) VALUES ('DEV-INVITE-001', 100);