Login — Get JWT Token

Authenticates a user with credentials. Returns a pair of access and refresh tokens.


Login / Get Token

Authorizations

The x-api-key header is required for authorization.

Endpoint

POSThttps://dev.backend.colurs.co/token/

Required Headers

Content-Type: application/jsonAccept: application/jsonx-api-key: [API_KEY]

Request Body

FieldTypeRequiredDescription
usernamestringUser email or username
passwordstringUser password
platformstringAPI, APP, PANEL, IOS, ANDROID (default: API)
codestringVerification code (required for PANEL, IOS, ANDROID)
otpstring6-digit 2FA code (if user has MFA enabled)

cURL Example

curl -X POST https://dev.backend.colurs.co/token/ \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "x-api-key: [API_KEY]" \
-d '{
  "username": "user@example.com",
  "password": "Password123!",
  "platform": "API"
}'

Response

response.json
{
"access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh": 
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."}

Possible Errors

CodeErrorDescription
400DataInvalidExceptionInvalid credentials or unsupported platform
400CodeMustBeRequiredExceptionCode required for PANEL/IOS/ANDROID
400CodeExpiredExceptionVerification code expired
400OTPRequiredException2FA code is required (user has MFA enabled)
400InvalidOTPExceptionInvalid 2FA code
⚠️
For **PANEL**, **IOS**, and **ANDROID** platforms, an additional verification `code` previously sent to the user is required.

Use the Token

⚠️

The access token expires in 15 minutes. Use the Refresh endpoint to get a new one without logging in again.

Include these headers in every authenticated request:

Content-Type: application/json
Accept: application/json
x-api-key: [API_KEY]
Authorization: Bearer [ACCESS_TOKEN]

2FA (MFA) Flow

If the user has two-factor authentication enabled (totp_secret in their profile), login requires an additional step:

  1. Send username, password, and platform as usual.
  2. The server responds with OTPRequiredException.
  3. Resend the same request adding the otp field with the 6-digit authenticator code.
  4. If the OTP is valid, you receive the tokens.
🔐

The OTP code uses TOTP (Time-based One-Time Password) with pyotp. Compatible with Google Authenticator, Authy, and similar apps.


Supported Platforms

PlatformDescriptionRequires code
APIExternal API integration
APPMain mobile application
PANELWeb admin panel
IOSiOS application
ANDROIDAndroid application