Login and receive JWT token
RESTAPIAuth
POST /api/v1/auth/login#
Overview#
Authenticates a user and returns a JWT Bearer token. The token is used in subsequent API calls via the Authorization: Bearer {token} header.
Authentication#
Request#
Method: POST
Path: /api/v1/auth/loginBody application/json#
{
"email": "marco.rossi@example.com",
"password": "SecurePass123!"
}
Body fields#
| Field | Type | Required | Description |
|---|
email | string | Yes | Registered email address |
password | string | Yes | Account password |
Response 200 OK#
{
"status": "success",
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"token_type": "Bearer",
"expires_in": 3600
}
}
Response fields#
| Field | Type | Description |
|---|
token | string | JWT token to use in Authorization: Bearer header |
token_type | string | Always "Bearer" |
expires_in | integer | Token lifetime in seconds |
Response 401 Unauthorized#
{
"status": "error",
"message": "Invalid credentials"
}
Response 422 Unprocessable Entity#
{
"status": "error",
"message": "The email field is required.",
"errors": {
"email": ["The email field is required."]
}
}
Notes#
Uses JWT via tymon/jwt-auth. Token TTL is configured in config/jwt.php.
Rate-limited (throttle:auth middleware) to prevent brute force attacks.
To refresh an expired token without re-authenticating, use POST /api/v1/auth/refresh.
Request
Body Params application/jsonRequired
{
"email": "user@example.com",
"password": "pa$$word"
}
Request Code Samples
curl --location 'https://diveraid.test/api/v1/auth/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com",
"password": "pa$$word"
}'
Responses
{
"status": "success",
"message": "string",
"data": {
"token": "string",
"token_type": "Bearer",
"expires_in": 0
}
}
Modified at 2026-04-14 15:19:38