Skip to main content
POST
Login

Endpoint

Overview

Authenticates a user with email and password. If 2FA is enabled, returns a pending token that requires verification code. Otherwise, returns a full JWT token and user’s service access information.

Request

string
required
User email address
string
required
User password
string
Required if 2FA is enabled. TOTP code from authenticator app.

Response (Without 2FA or Valid Code)

object
Authenticated user object
string
JWT token for authentication
array
Array of user’s service entitlements
boolean
Whether the user account is banned
boolean
Whether the user account is disabled

Response (2FA Required)

object
Partial user object (without sensitive data)
boolean
Always true when 2FA is required
string
Temporary token for 2FA verification. Not a full JWT token.
string
“2FA verification required”

Implementation Details

Process Flow

  1. CORS & Arcjet: Validates CORS and applies rate limiting
  2. User Lookup: Finds user with service access included
  3. Password Verification: Compares password with bcrypt hash
  4. 2FA Check: If enabled, validates verification code or returns pending token
  5. Session Management:
    • Reuses existing session if valid and from same IP
    • Creates new session if none exists
    • Updates expiration on existing sessions
  6. Audit Logging: Logs USER_LOGIN and SESSION_CREATE (if new session)

Code Reference

Status Codes

OK
Login successful (with or without 2FA)
Bad Request
Validation error
Unauthorized
Invalid credentials or invalid 2FA code
Forbidden
Blocked by Arcjet
Internal Server Error
Server error or 2FA configuration error

Example Requests

Without 2FA

With 2FA

Session Reuse Logic

The endpoint implements smart session reuse:
  • If a valid session exists for the user from the same IP, it reuses the token
  • Session expiration is updated on reuse
  • New sessions are only created when none exist or existing session is invalid

Audit Events

  • USER_LOGIN: Successful login (includes twoFactorUsed flag)
  • SESSION_CREATE: New session created (only if new session was created)

Body

application/json
email
string<email>
required
password
string
required
verificationCode
string

Required if 2FA is enabled

Response

Login successful

user
object
token
string
services
object[]
banned
boolean

Whether the user account is banned

disabled
boolean

Whether the user account is disabled