/api/v1/auth unless otherwise noted.
| Flow | Endpoint(s) | Description |
|---|---|---|
| Email/password | POST /signup, POST /signin | Create or authenticate users with the native database connection |
| Google OAuth | POST /google, POST /login/google, GET /login/google, GET /callback/google | Exchange Google ID tokens or run the redirect-based flow |
| Tokens | POST /refresh, POST /signout | Rotate or revoke Auth0 tokens |
| Profile | GET /me, PATCH /me | Full profile overview with usage stats, update profile with avatar upload |
| Phone OTP | POST /send-otp, POST /resend-otp, POST /verify-otp | Exotel-backed OTP login |
| Webhooks | POST /webhooks/post-registration, POST /post-login | Auth0 server-to-server sync |
| Health | GET /health | Service heartbeat |
Prerequisites
- Auth0 tenant with the database connection enabled and client credentials set
in
.env(AUTH0_DOMAIN,AUTH0_CLIENT_ID, etc.). - Front-channel URLs registered in Auth0 for
GET /login/googleandGET /callback/google. - Exotel credentials for OTP routes and a verified sender ID.
- Bearer token (Auth0 access token) when hitting any protected route such as
/api/v1/auth/me. UsePOST /signinor/googleto obtain one.
Email + password
- Password must be ≥8 chars and include uppercase, lowercase, and a digit
(signupRequestSchemainsrc/services/auth/types/auth-schemas.ts). - Successful signup/signin returns
{ accessToken, idToken, refreshToken, expiresIn, user }.
POST /signin takes the same body (email + password) and returns the same
envelope. Tokens are Auth0-issued JWTs referenced throughout the API.
Google OAuth
1. Token exchange (mobile/native)
POST /api/v1/auth/google panel.
2. Redirect flow (web)
GET /api/v1/auth/login/google→ redirects to Auth0’s hosted login page (optionalstatequery param supported).GET /api/v1/auth/callback/google→ handles the authorization code, fetches user info, syncs MongoDB viauserSyncService, and forwards the tokens plus the originalstateback to the frontend.
authOrchestrationService.googleAuth() and return the standard
token envelope.
Token lifecycle
Refresh
POST /api/v1/auth/refresh with body { "refreshToken": "<token>" } returns
{ accessToken, idToken, expiresIn }. No Bearer token required—the refresh token
is validated via Auth0 (tokenService.refreshAccessToken).
Use the Refresh Access Token playground to verify your refresh
tokens are wired correctly.
Signout
POST /api/v1/auth/signout accepts an optional refreshToken. When provided,
the backend revokes it via Auth0; when omitted, the call simply returns
{ success: true, message: "Successfully signed out" } so clients can clear
local state.
Profile (GET & PATCH /me)
The/me endpoint is the unified profile endpoint that replaces the old /profile route.
Get Profile
GET /api/v1/auth/me requires Authorization: Bearer <Access Token>. Returns the
full profile overview including user data, usage statistics, and profile context:
Update Profile
PATCH /api/v1/auth/me accepts partial updates for fullName or preferences
(language, theme, notifications), and supports avatar upload via multipart form data.
Returns the updated profile overview.
JSON Request (no avatar):
Phone OTP (Exotel)
Phone OTP authentication via Exotel SMS. All routes are under/api/v1/auth.
Required Headers
| Header | Required | Description |
|---|---|---|
x-device-id | Yes | Stable, unique per device/installation |
x-platform | No | ios, android, or web |
Send OTP
otpOrchestrationService.sendOTP.
Resend OTP
OTP_RESEND_COOLDOWN_SECONDS (default 60s) before dispatching another SMS.
Verify OTP
accessToken can be used with all authenticated endpoints just like email/password tokens.
Webhooks (server-to-server)
| Endpoint | Auth | Purpose |
|---|---|---|
POST /api/v1/auth/webhooks/post-registration | Auth0 JWT + optional X-Webhook-Secret | Primary hook triggered by Auth0 Actions after signup to create the MongoDB user |
POST /api/v1/auth/post-login | Auth0 JWT | Legacy hook for syncing profile updates after login |
auth0JwtMiddleware and are not intended for client apps.
Health
GET /api/v1/auth/health returns the provider info and the exported endpoints,
useful for monitoring or smoke tests.
Error format
All controllers extendBaseController and emit the shared error envelope: