Authentication
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!"
}'import axios from 'axios';
const response = await axios.post(
'https://api.reten.ai/api/auth/login',
{
identifier: 'admin@example.com',
password: 'SecurePass123!',
}
);
const { accessToken, user } = response.data;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 |