Authentication¶
The Madevo API uses JWT-based authentication for all secure endpoints.
Overview¶
Authentication works as follows:
- Login to obtain a JWT token
- Include the token in all secure requests
- Refresh the token when it expires
- Logout to revoke the session
Login¶
Endpoint¶
Request¶
Headers¶
Body¶
Response¶
{
"error": false,
"message": "login successful",
"user": {
"id": "string",
"email": "string",
"first_name": "string",
"last_name": "string",
"company_id": "string",
"role": "string",
"is_active": true,
"meta": {},
"created_at": "string"
},
"token": "<jwt>"
}
Notes¶
- The
tokenis required for all secure endpoints - Login fails if credentials are invalid or account is inactive
Example¶
curl -X POST https://api.example.com/api/v1/login \
-H 'Content-Type: application/json' \
-d '{
"email": "user@example.com",
"password": "Password1!"
}'
Using the token¶
All secure endpoints require:
Example¶
Token lifecycle¶
- Access token lifetime: 15 minutes
- Session lifetime: 7 days
If the token is invalid:
Refresh token¶
Endpoint¶
Request¶
Headers¶
Body¶
Response¶
{
"error": false,
"message": "token refreshed",
"user": {
"id": "string",
"email": "string"
},
"token": "<new-jwt>"
}
Notes¶
- Token must be provided in both header and body
- Session must still be valid
Logout¶
Endpoint¶
Request¶
Response¶
WebSocket authentication¶
Use the token as a query parameter:
Best practices¶
- Store tokens securely
- Refresh tokens before expiry
- Do not expose tokens in logs
- Handle authentication errors gracefully