Skip to main content

Authentication API

POST /api/auth/register

Create a new analyst account.

Auth: Public (no authentication required)

Content-Type: application/json

Request Body:

FieldTypeRequiredDescription
emailstringYesEmail address (must be unique)
passwordstringYesPassword (minimum 8 characters)
namestringNoDisplay name

Success Response (201):

{
"success": true
}

Error Responses:

StatusBodyCause
400{ "error": "Email and password are required" }Missing fields
400{ "error": "Password must be at least 8 characters" }Password too short
409{ "error": "Email already in use" }Duplicate email
500{ "error": "Failed to register" }Server error

Notes:

  • Passwords are hashed with bcrypt (12 rounds) before storage
  • After registration, use the NextAuth sign-in endpoint to obtain a session

GET/POST /api/auth/[...nextauth]

NextAuth.js session handler. Manages sign-in, sign-out, session validation, and CSRF token generation.

Auth: Varies by operation

This is a catch-all route handled by NextAuth.js. The primary sub-routes are:

RouteMethodPurpose
/api/auth/signinGET/POSTSign in with credentials
/api/auth/signoutPOSTSign out and clear session
/api/auth/sessionGETGet current session
/api/auth/csrfGETGet CSRF token

Sign-In Request:

POST /api/auth/callback/credentials
Content-Type: application/x-www-form-urlencoded

email=analyst@example.com&password=mypassword&csrfToken=...

Session Response (GET /api/auth/session):

{
"user": {
"id": "clxx...",
"email": "analyst@example.com",
"name": "Jane Doe"
},
"expires": "2026-05-08T..."
}

Notes:

  • Sessions use JWT stored in an HTTP-only cookie
  • Session strategy: JWT (no database sessions)
  • Custom sign-in page: /login