Auth and workspace endpoints
Authentication
Signup, sign-in and sign-out go through the API rather than the Supabase browser client, so session cookies are set by the server.
POST /api/auth/register
Creates the Supabase user, then a Profile, a Subscription and a SubscriptionUser with role
owner.
- Body
-
{ "email": "…", "password": "…", "name": "…" } - Response
-
{ "success": true }or{ "user_id": "…" }
The client must then call POST /api/auth/signin with the same credentials to establish the session.
Password strength is checked by lib/auth/password-strength.ts, and the email domain by
isAllowedPayabilityEmail().
Workspace selection
Members
All member endpoints operate on the current workspace, resolved from the cookie or header.
GET /api/subscriptions/members
- Response
-
{ "data": [{ "id", "profile_id", "name", "role", "joined_at" }], "total": n }
Member data comes from Profile only; there is no Supabase Admin API call, so the endpoint stays fast
and needs no service-role key.
POST /api/subscriptions/members
Owner or admin only.
- Body
-
{ "email": "user@example.com", "role": "member" | "admin" | "owner" }
Looks up the Profile by email and creates a SubscriptionUser. Only owners may add an owner.
- Response
-
201 { "success": true }
The invitee must already have a Profile — that is, they must have signed up. There is no
invitation-by-email flow.
Legacy agent endpoints
GET /api/agents and PATCH /api/agents operate on Profile as a calling agent — the
JustCall-era human availability model.
GET /api/agents accepts isAvailable and selectRandom, and derives an availability value:
| Value | Condition |
|---|---|
|
|
|
|
|
|
PATCH /api/agents updates the caller’s own record (name, max_concurrent_calls, availability).
Current rep identity lives on SalesRep — see Sales rep and task endpoints.
Workspace config
Key/value rows in the configs table, scoped to the active workspace. Values are always strings;
callers coerce them (for example feature flags via ConfigRepository.isValueEnabled).
key is globally unique rather than unique per workspace — creating a key that already exists
returns 409.
GET /api/configs
- Response
-
{ "data": [{ "id", "key", "value", "created_at", "updated_at" }], "total": n }