Repository navigation
Authentication Endpoints
github-actions[bot] edited this page Aug 30, 2026
·
5 revisions
**Referenced Files in This Document**
- [auth.ts](file://server/routes/auth.ts)
- [routes.ts](file://server/routes.ts)
- [auth-workspace.ts](file://server/lib/auth-workspace.ts)
- [schema.ts](file://shared/schema.ts)
- [pg-queries.ts](file://server/lib/pg-queries.ts)
- Introduction
- Core Endpoints
- Password Management
- Email Verification
- Workspace Invitations
- Security & Session Management
- Conclusion
This document provides comprehensive API documentation for the workspace-based local authentication system. All authentication is handled via HttpOnly cookies and JWT tokens.
-
Path:
POST /api/auth/signup - Purpose: Creates a new user and an associated workspace.
-
Request Body:
-
name: string (Full name) -
email: string (Unique email) -
password: string (min 6 chars) -
workspaceName: string (The name of the initial workspace)
-
-
Response:
201 Createdwith User + Active Workspace payload.
-
Path:
POST /api/auth/login - Purpose: Authenticates a user and issues session cookies.
-
Request Body:
-
email: string -
password: string
-
-
Response:
200 OKwith User + Active Workspace payload.
-
Path:
POST /api/auth/refresh - Purpose: Regenerates a short-lived access token using a long-lived refresh token.
-
Security: Requires a valid
refresh_tokencookie. Issues a rotated refresh token to prevent replay attacks.
-
Path:
POST /api/auth/logout - Purpose: Invalidates the current session and clears cookies.
-
Path:
GET /api/auth/me - Purpose: Returns the currently authenticated user's profile and workspace context.
-
Path:
POST /api/auth/password/forgot -
Body:
{ "email": "user@example.com" } - Action: Sends a password reset link to the user's email.
-
Path:
POST /api/auth/password/reset -
Body:
{ "token": "...", "password": "..." } - Action: Updates the password and invalidates all active sessions.
-
Path:
POST /api/auth/email/verify/request - Action: Sends a verification link to the logged-in user's email.
-
Path:
POST /api/auth/email/verify -
Body:
{ "token": "..." } - Action: Marks the user's email as verified in the database.
-
Path:
POST /api/workspaces/:id/invites -
Body:
{ "email": "...", "role": "admin|member", "kind": "business_member|student" } - Auth: Requires "owner" or "admin" role in the target workspace.
-
Path:
GET /api/invite/validate/:token - Action: Checks if an invite token is valid and returns workspace metadata.
-
Path:
POST /api/auth/workspace-invite/signup -
Body:
{ "token": "...", "password": "...", "displayName": "..." } -
Action: Creates a user and joins them to the workspace. An email that
already has an account is refused with
409 { accountExists: true }and must sign in instead. -
Note: the former
POST /api/invite/acceptwas removed. It was unauthenticated and issued a session for an existing account without checking the password, so invite possession alone was enough to sign in as that user.
All session data is delivered via secure, HttpOnly cookies:
-
access_token: JWT containinguserIdandsessionId. Expires in 15m. -
refresh_token: Opaque string mapped to a database session. Expires in 30d.
Passwords are never stored in plain text. The system uses BcryptJS with 12 salt rounds.
Authentication endpoints are protected by rate limiters to prevent brute-force attacks.
The API has transitioned from a Firebase-managed model to a self-hosted, secure, and multi-tenant transactional system. Developers should ensure that all requests include the credentials: 'include' flag (for Fetch/XHR) to correctly transmit session cookies.