POST/api/auth

Login

Authenticate a user with their email and password to receive JWT access and refresh tokens.

Request

Body Parameters

ParameterTypeRequiredDescription
emailstringYesUser's email address
passwordstringYesUser's password

Example Request

curl -X POST https://api.storno.ro/api/auth \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "your-secure-password"
  }'

Response

Success Response (200 OK)

{
  "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "def50200a1b2c3d4e5f6..."
}
FieldTypeDescription
tokenstringJWT access token, valid for 1 hour
refresh_tokenstringRefresh token used to obtain new access tokens

Error Codes

CodeDescription
400Bad Request - Missing or invalid parameters
401Unauthorized - Invalid email or password
403Forbidden - Account is inactive or email not confirmed
429Too Many Requests - Rate limit exceeded

Error Response Examples

Invalid Credentials (401)

{
  "code": 401,
  "message": "Invalid credentials."
}

Email Not Confirmed (403)

{
  "code": 403,
  "message": "Please confirm your email address before logging in."
}

Account Inactive (403)

{
  "code": 403,
  "message": "Your account has been deactivated. Please contact support."
}

MFA Challenge Response (200 OK)

If the user has two-factor authentication enabled, the login endpoint returns an MFA challenge instead of tokens:

{
  "mfa_required": true,
  "mfa_token": "a1b2c3d4e5f6789...",
  "mfa_methods": ["totp", "backup_code"]
}
FieldTypeDescription
mfa_requiredbooleanAlways true when MFA is needed
mfa_tokenstring64-character challenge token (valid for 5 minutes)
mfa_methodsstring[]Available verification methods: totp and/or backup_code

Complete the challenge by calling Verify MFA Challenge with the mfa_token and a valid code.

Usage Notes

  • Store the token securely (e.g., in memory or secure storage)
  • Include the token in subsequent requests via the Authorization: Bearer {token} header
  • Use the refresh_token to obtain a new access token when it expires
  • Tokens are rotated on refresh for enhanced security
  • Rate limiting applies: maximum 5 login attempts per minute per IP address
  • When the user has MFA enabled, handle the mfa_required response by redirecting to MFA verification