Authentication — Overview
Every call to the AgFlow API, except the login endpoint itself, requires a Bearer access token. This section describes the authentication flow used across the entire API.Endpoints in this domain#
| Method | Path | Description |
|---|
POST | /api/login | Authenticates the user and returns the access token |
Note on host: the authentication endpoint runs on a different host than the other AgFlow API endpoints documented in this project. The full authentication URL is https://agflow.agrisk.app/api/login. The other routes use a different base host — do not reuse this host for other calls, and do not use the other calls' base host for login.
How to authenticate#
Send a POST request to /api/login with a body containing credential (email address or username) and password. On success, the response includes an accessToken — a JWT that must be sent in the Authorization header of every subsequent API call, formatted as Authorization: Bearer <accessToken>.The returned token has a short lifetime, on the order of minutes. We recommend re-authenticating periodically rather than assuming a long-lived token, and treating 401 responses on other calls as a signal to request a new token.In addition to the Authorization header, some endpoints related to phases and other resources within a flow also require the ag-flow-id header, containing the identifier of the flow the call refers to. This header is additional to Authorization, not a replacement for it. Check each endpoint's documentation to confirm whether it is required.Important behaviors#
The login request body uses the key credential, not email. Sending email instead of credential results in a server error.
The credential field accepts either an email address or a username registered in AgFlow.
The login endpoint runs on a different host than the rest of the API (https://agflow.agrisk.app) — do not use the same base host configured for the other calls.
The returned token (accessToken) must be sent as Authorization: Bearer <accessToken> on every other API call.
Some phase endpoints and other resources within a flow also require the ag-flow-id header, containing the flow identifier.
Modificado em 2026-07-28 20:38:32