Authentication¶
Login with email and either a password or a code (OTP)—not both. Returns JWT tokens.
No authentication required (to get tokens).
| Field | Type | Required | Description |
|---|---|---|---|
email |
string | Yes | User's email address |
password |
string | One of these | User's password (use with Option A only) |
otp |
string | One of these | 6-digit code from email/SMS (use with Option B only) |
You must provide exactly one of password or otp. Do not send both; do not omit both.
Response¶
Both password and code provided:
Neither password nor code provided:
Invalid credentials (password login):
orInvalid or missing OTP (code login):
orError Cases¶
- Both / neither: Sending both
passwordandotp, or neither. - Invalid credentials: Wrong email or password (password login).
- Inactive account: Account is not activated.
- Invalid OTP: Code incorrect, expired, or already used (code login).
- No OTP: No valid OTP found for the email (request a new one).
Request login OTP¶
For code (OTP) login, the client should request a login OTP first (active accounts only). ZeptoMail uses ZEPTOMAIL_OTP_LOGIN_TEMPLATE_KEY when set; otherwise ZEPTOMAIL_OTP_TEMPLATE_KEY. Merge payload includes purpose (login or activation) for template branching if needed.
JWT Tokens¶
Access Token¶
- Lifetime: 3 hours
- Usage: Include in
Authorizationheader for authenticated requests - Format:
Bearer <access_token>
Refresh Token¶
- Lifetime: 7 days
- Usage: Use to get a new access token when it expires
- Endpoint:
/api/token/refresh/(if implemented)
Using the Access Token¶
Include the access token in the Authorization header:
curl -X GET https://api.endovillehealth.com/api/users/profile/ \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
Notes¶
- Use either password or code to login, not both.
- The account must be activated (
is_active=True). - For code login: call
POST /api/users/request-login-otp/first, thenPOST /api/users/login/with the sameemailand theotpfrom the email. OTP is single-use, expires after 5 minutes, and has a maximum of 3 verification attempts. - Store the access token securely (e.g., in localStorage or secure cookies).
- Use the refresh token to obtain a new access token before it expires.
Example Requests¶
Password login:
curl -X POST https://api.endovillehealth.com/api/users/login/ \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "securepassword123"}'
Code (OTP) login: