Authentication
ZapTicket uses a two-level JWT flow. First authenticate as a user, then select a workspace to get a scoped workspace token.
Overview
Authentication in ZapTicket is a two-step process. When you register or log in, you receive a user token — this identifies you as a person but does not grant access to any workspace data. To interact with conversations, tickets, or settings, you must select a workspace which returns a workspace token scoped to that tenant.
Token Flow
1. POST /auth/register → user token (no workspace context)
OR
POST /auth/login → user token (no workspace context)
2. GET /workspaces → list of workspaces user belongs to
(requires user token)
3. POST /workspaces/{id}/select → workspace token (scoped to tenant)
(requires user token)
4. Use workspace token for all subsequent API calls
Authorization: Bearer <workspace_token>Endpoints
Register
/auth/registerCreate a new user account. Returns a user-level JWT.
Auth: None
{
"email": "[email protected]",
"password": "SecureP@ss123",
"fullName": "Jane Smith"
}{
"token": "eyJhbGciOiJIUzI1NiIs...",
"user": {
"id": "usr_abc123",
"email": "[email protected]",
"fullName": "Jane Smith",
"emailVerified": false,
"createdAt": "2024-01-15T10:30:00Z"
}
}409 Conflict with an error message. Passwords must be at least 8 characters with one uppercase, one lowercase, and one number.Login
/auth/loginAuthenticate with email and password. Returns a user-level JWT.
Auth: None
{
"email": "[email protected]",
"password": "SecureP@ss123"
}{
"token": "eyJhbGciOiJIUzI1NiIs...",
"user": {
"id": "usr_abc123",
"email": "[email protected]",
"fullName": "Jane Smith",
"emailVerified": true,
"createdAt": "2024-01-15T10:30:00Z"
}
}Returns 401 Unauthorized if credentials are invalid. The login endpoint is rate-limited to 10 attempts per 5 minutes per IP to prevent brute-force attacks.
Get Current User
/auth/meReturns the authenticated user's profile and a list of workspaces they belong to.
Auth: User token or Workspace token
{
"id": "usr_abc123",
"email": "[email protected]",
"fullName": "Jane Smith",
"emailVerified": true,
"createdAt": "2024-01-15T10:30:00Z",
"workspaces": [
{
"id": "ws_xyz789",
"name": "Acme Inc",
"slug": "acme-inc",
"role": "admin"
}
]
}Verify Email
/auth/verify-emailVerify a user's email address using the token sent to their inbox.
Auth: None (token in query param)
GET /auth/verify-email?token=eyJhbGciOiJIUzI1NiIs...{
"message": "Email verified successfully"
}Returns 400 Bad Request if the token is expired or invalid. Verification tokens expire after 24 hours, after which the user must request a new one.
Using Tokens
Include the JWT in the Authorization header for all authenticated requests:
curl -X GET https://api.zapticket.app/conversations \
-H "Authorization: Bearer <workspace_token>" \
-H "Content-Type: application/json"