Authenticates a user and returns an API token for subsequent requests.
| Name | Type | Required | Description | Example |
|---|---|---|---|---|
| phone | string | Yes | User phone number | "+989123456789" |
| password | string | Yes | User password | "password123" |
| expiration | int | No | Token expiration in seconds (optional; if omitted, token never expires) | 3600 |
| token_name | string | No | Optional name for the token (defaults to user agent if not provided) | "MyAppToken" |
{
"phone": "+989123456789",
"password": "password123",
"expiration": 3600,
"token_name": "MyAppToken"
}
Returns the API token.
{
"token": "<the API token will be set here>"
}
| Status | Description | Example/Reference |
|---|---|---|
| 403 | Invalid credentials | { "error": "Invalid credentials" } |
| 422 | Validation error | Validation error |
| 429 | Too many requests | Rate-limit error |
After logging in and receiving the token, save it on the client side (e.g., in a cookie or local storage). For every subsequent API call, pass the token as a Bearer token in the headers:
Authorization: Bearer {token}