AgroPulse uses a simple credential-exchange model: you POST your credentials toDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/diarpicu2022-commits/backend-AgroPulse/llms.txt
Use this file to discover all available pages before exploring further.
/api/auth/login and receive a user object back. That object contains everything you need—your role, your assigned greenhouse IDs, and your profile—and you store it client-side. There are no expiring tokens to refresh; identity for privileged operations is asserted via the X-Admin-Email header on requests that need it.
AgroPulse does not issue Bearer tokens. The response to a successful login is a plain JSON user object. Your client is responsible for persisting this object (for example, in
localStorage) and reading it back for subsequent requests.Login flows
- Standard login
- Google login
POST to You can also log in by email instead of username:
/api/auth/login with a username (or email) and password. The API checks the credential against the stored BCrypt hash and returns the user object on success.Registering a new account
New users can self-register with a username and password. All self-registered accounts receive theOPERATOR role. An admin must promote the role afterwards if needed.
User object
Both login and register return the same sanitized user object. Passwords are never included in responses.| Field | Type | Description |
|---|---|---|
id | integer | Unique user ID |
username | string | Login username |
fullName | string | Display name |
email | string | Email address |
phone | string | Phone number, used for WhatsApp alerts |
avatar | string | Profile image URL (populated from Google) |
role | string | One of ADMIN, OPERATOR, AGRONOMIST, VIEWER |
active | boolean | Whether the account is enabled |
createdAt | string | ISO-8601 timestamp of account creation |
greenhouseIds | array | Greenhouse IDs this user has access to |
User roles
| Role | Capabilities |
|---|---|
ADMIN | Full access to all endpoints. Can list users, change roles, assign greenhouses, and perform all OPERATOR actions. Admin identity is verified via the X-Admin-Email header. |
OPERATOR | Standard operational access: view sensor readings, manage sensors and greenhouses assigned to them, acknowledge alerts. Default role for all new accounts. |
AGRONOMIST | Read access to readings and anomalies; intended for agronomists who need data without write access. |
VIEWER | Read-only access. Cannot modify any resource. |
Admin operations
Endpoints that list all users or change roles require you to pass theX-Admin-Email header. The server compares this value against the AGROPULSE_ADMIN_EMAIL environment variable. If they match, the request is treated as admin-authorized.
AGROPULSE_ADMIN_EMAIL environment variable to the email address that should have admin rights.