AgroPulse authenticates requests using JSON Web Tokens (JWT) issued by the SimpleJWT library. Every protected endpoint requires a valid access token in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/OluwagbeminiyiA/agro_pulse-API/llms.txt
Use this file to discover all available pages before exploring further.
Authorization header. Access tokens are short-lived; when they expire you use a refresh token to obtain a new one without asking the user to log in again. Tokens are issued against a specific user account and carry that user’s role (BUYER, SELLER, or TRANSPORTER), which the API uses to enforce access control.
Obtain a token
Send the user’s email and password to/api/token/. On success the API returns both an access token and a refresh token.
Pass the token in requests
Include the access token in theAuthorization header of every request to a protected endpoint. The scheme must be Bearer.
Refresh an expired token
When the access token expires, use the refresh token to obtain a new one without re-entering credentials. Send the refresh token to/api/token/refresh/.
Token lifetimes
SimpleJWT ships with a default access token lifetime of 5 minutes and a refresh token lifetime of 1 day. Your deployment may override these values in
SIMPLE_JWT settings. Check with your administrator if you are unsure what lifetimes are in effect.| Token | Default lifetime |
|---|---|
| Access | 5 minutes |
| Refresh | 1 day |
401 Unauthorized responses and automatically call /api/token/refresh/ before retrying the original request.
Authentication errors
| Status | Meaning | Common cause |
|---|---|---|
401 Unauthorized | Token absent, malformed, or expired | Missing Authorization header; expired access token not yet refreshed |
403 Forbidden | Token valid but insufficient permissions | Authenticated user’s role does not have access to the requested endpoint |
Role-based access
Every user account has arole field set at registration time. The API enforces role-based access control on each endpoint:
| Role | Description |
|---|---|
BUYER | Can browse produce, place orders, and initialize payments. |
SELLER | Can create and manage produce listings and fulfil orders. Registered as a SELLER; displayed as “farmer” in the data model. |
TRANSPORTER | Can accept delivery assignments and update delivery status. |