Skip to main content
POST
/
authentication
/
login
curl -X POST https://api.sapfiai.com/authentication/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "SecureP@ssw0rd"
  }'
{
  "success": false,
  "token": null,
  "refreshToken": null,
  "user": null,
  "message": "Login failed",
  "errors": [
    "Invalid email or password"
  ],
  "requires2FA": false
}
Authenticate a user and receive access tokens.

Authentication

This endpoint does not require authentication.

Request Body

email
string
required
User’s email address.
password
string
required
User’s password. Must be at least 6 characters.

Response

success
boolean
Indicates whether the login was successful.
token
string
JWT access token for authenticating subsequent requests.
refreshToken
string
Refresh token for obtaining new access tokens.
refreshTokenExpiry
string
Expiration date and time of the refresh token (ISO 8601 format).
user
object
User information object.
message
string
A message describing the result of the operation.
errors
string[]
Array of error messages if login failed.
requires2FA
boolean
If true, the user must complete two-factor authentication using the /authentication/verify-2fa endpoint.

Error Responses

{
  "success": false,
  "token": null,
  "refreshToken": null,
  "user": null,
  "message": "Login failed",
  "errors": [
    "Invalid email or password"
  ],
  "requires2FA": false
}
curl -X POST https://api.sapfiai.com/authentication/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "SecureP@ssw0rd"
  }'
{
  "success": true,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refreshToken": "8f7d6e5c4b3a2918e7f6d5c4b3a29180",
  "refreshTokenExpiry": "2026-04-05T10:30:00Z",
  "user": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "email": "[email protected]",
    "userName": "johndoe",
    "phoneNumber": "+1234567890",
    "twoFactorEnabled": false,
    "lastLoginDate": "2026-03-05T10:30:00Z",
    "lastLoginIp": "192.168.1.1"
  },
  "message": "Login successful",
  "errors": null,
  "requires2FA": false
}

Build docs developers (and LLMs) love