Ferred authenticates users with JWT tokens. Send credentials toDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Carlos-Gnd/FERRED-Inventario-y-Ventas/llms.txt
Use this file to discover all available pages before exploring further.
POST /api/auth/login to receive a token, then include it as a Bearer token in all subsequent requests. Tokens are stateless — the server does not maintain sessions. If the cloud database is unreachable, login automatically falls back to the local SQLite replica.
POST /api/auth/login
Validates an email/password pair and returns a signed JWT token together with basic user information. Endpoint:POST https://server-production-3252.up.railway.app/api/auth/login
Request body
The user’s email address. Normalized to lowercase before lookup.
The user’s password. Minimum 1 character.
Response
Signed JWT to use as a Bearer token in subsequent requests. The token encodes
id, rol, sucursalId, and email.Basic profile of the authenticated user.
Error responses
| Status | Condition |
|---|---|
400 | Request body fails validation (missing email, invalid format, empty password). Response: { "error": "<message>" } |
401 | Credentials are incorrect or the account is inactive. Response: { "error": "Credenciales incorrectas" } |
503 | Both the cloud database and the local SQLite replica are unavailable. Response: { "error": "Servicio no disponible. Intente de nuevo cuando haya conexión." } |
login
Usar el token
Include the token in every request to a protected endpoint using theAuthorization header with the Bearer scheme.
authenticated request
POST /api/auth/logout
Endpoint:POST https://server-production-3252.up.railway.app/api/auth/logout
Logout is handled client-side. The server returns { "ok": true } and performs no server-side token invalidation. Your client is responsible for discarding the token from storage (memory, localStorage, secure storage, etc.) so it is no longer sent in future requests.
Modo offline
When the cloud PostgreSQL database is unreachable (network error, Prisma connection timeout, or Railway outage), the login endpoint automatically retries against the local SQLite replica instead of returning an error.- If SQLite credentials are valid, the response is identical to a normal login response.
- The response will include an extra header:
When login succeeds via the local replica, the server sets the response header
X-Auth-Mode: offline. Check for this header if your client needs to indicate to the user that they are operating in offline mode.401 regardless of whether the check runs against PostgreSQL or SQLite. The 503 status is only returned when both databases are unavailable.
Token payload
The JWT contains the following claims, which you can decode on the frontend (e.g. withjwt-decode) without making an additional request:
| Claim | Type | Description |
|---|---|---|
id | number | Internal user ID |
rol | string | User role: ADMIN, CAJERO, or BODEGA |
sucursalId | number | null | Branch the user belongs to |
email | string | User email address |
The
nombre (display name) is returned in the login response body but is not included in the JWT payload. Store it separately after login if you need it without an additional API call.