Login
Authenticate a user and receive access and refresh tokens.
POST /api/auth/login
Authenticate a user with username or email and password. Returns an access token in the response body and sets a refresh token as an HTTP-only cookie.
Auth: Public (no authentication required)
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
identifier | string | Yes | Username or email address |
password | string | Yes | User password (minimum 8 characters) |
Example
curl -X POST https://api.reten.ai/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"identifier": "admin@example.com",
"password": "SecurePass123!"
}'const response = await fetch("https://api.reten.ai/api/auth/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
identifier: "admin@example.com",
password: "SecurePass123!",
}),
});
const data = await response.json();
const accessToken = data.accessToken;import requests
response = requests.post(
"https://api.reten.ai/api/auth/login",
json={
"identifier": "admin@example.com",
"password": "SecurePass123!",
},
)
data = response.json()
access_token = data["accessToken"]Response 200 OK
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "admin@example.com",
"firstName": "Admin",
"lastName": "User"
}
}The refresh token is set as an HTTP-only cookie (refreshToken) with a 7-day expiration.
Error Responses
| Status | Description |
|---|---|
401 | Invalid email or password |