Overview
Users belong to a tenant and have specific roles that determine their access level within the system. Each user can access greenhouses, view sensor data, and manage alerts based on their role.
Get All Users for Tenant
GET /api/v1/tenants/{tenantId}/users
curl -X GET "https://api.invernaderos.com/api/v1/tenants/1/users" \
-H "Authorization: Bearer YOUR_TOKEN"
Retrieve all users belonging to a specific tenant.
Path Parameters
Unique identifier of the tenant
Response
Unique identifier of the user
Unique readable code (e.g., “USR-00001”)
User role (ADMIN, OPERATOR, VIEWER)
ID of the tenant the user belongs to
Whether the user account is active
Last login timestamp (ISO 8601)
Creation timestamp (ISO 8601)
Last update timestamp (ISO 8601)
[
{
"id" : 1 ,
"code" : "USR-00001" ,
"username" : "jdoe" ,
"email" : "[email protected] " ,
"role" : "ADMIN" ,
"tenantId" : 1 ,
"isActive" : true ,
"lastLogin" : "2025-03-03T10:30:00Z" ,
"createdAt" : "2025-03-01T10:00:00Z" ,
"updatedAt" : "2025-03-01T10:00:00Z"
},
{
"id" : 2 ,
"code" : "USR-00002" ,
"username" : "msmith" ,
"email" : "[email protected] " ,
"role" : "OPERATOR" ,
"tenantId" : 1 ,
"isActive" : true ,
"lastLogin" : "2025-03-02T15:20:00Z" ,
"createdAt" : "2025-03-01T11:00:00Z" ,
"updatedAt" : "2025-03-01T11:00:00Z"
}
]
Get User by ID
GET /api/v1/tenants/{tenantId}/users/{userId}
curl -X GET "https://api.invernaderos.com/api/v1/tenants/1/users/1" \
-H "Authorization: Bearer YOUR_TOKEN"
Retrieve a specific user belonging to a tenant.
Path Parameters
Unique identifier of the tenant
Unique identifier of the user
Response
200 - Success
404 - Not Found
{
"id" : 1 ,
"code" : "USR-00001" ,
"username" : "jdoe" ,
"email" : "[email protected] " ,
"role" : "ADMIN" ,
"tenantId" : 1 ,
"isActive" : true ,
"lastLogin" : "2025-03-03T10:30:00Z" ,
"createdAt" : "2025-03-01T10:00:00Z" ,
"updatedAt" : "2025-03-01T10:00:00Z"
}
Create User
POST /api/v1/tenants/{tenantId}/users
curl -X POST "https://api.invernaderos.com/api/v1/tenants/1/users" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"username": "jdoe",
"email": "[email protected] ",
"passwordRaw": "SecurePassword123!",
"role": "OPERATOR",
"isActive": true
}'
Create a new user for a tenant.
Path Parameters
Unique identifier of the tenant
Request Body
Username for login (must be unique)
Email address (must be valid and unique)
User’s password (will be hashed before storage)
User role: ADMIN, OPERATOR, or VIEWER
Whether the user account is active
Response
{
"id" : 3 ,
"code" : "USR-00003" ,
"username" : "jdoe" ,
"email" : "[email protected] " ,
"role" : "OPERATOR" ,
"tenantId" : 1 ,
"isActive" : true ,
"lastLogin" : null ,
"createdAt" : "2025-03-03T21:45:00Z" ,
"updatedAt" : "2025-03-03T21:45:00Z"
}
Update User
PUT /api/v1/tenants/{tenantId}/users/{userId}
curl -X PUT "https://api.invernaderos.com/api/v1/tenants/1/users/1" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"role": "ADMIN",
"isActive": true
}'
Update an existing user. All fields are optional.
Path Parameters
Unique identifier of the tenant
Unique identifier of the user to update
Request Body
All fields are optional. Only provided fields will be updated.
New password (if changing)
User role (ADMIN, OPERATOR, VIEWER)
Whether the user account is active
Response
200 - Success
404 - Not Found
{
"id" : 1 ,
"code" : "USR-00001" ,
"username" : "jdoe" ,
"email" : "[email protected] " ,
"role" : "ADMIN" ,
"tenantId" : 1 ,
"isActive" : true ,
"lastLogin" : "2025-03-03T10:30:00Z" ,
"createdAt" : "2025-03-01T10:00:00Z" ,
"updatedAt" : "2025-03-03T21:50:00Z"
}
Delete User
DELETE /api/v1/tenants/{tenantId}/users/{userId}
curl -X DELETE "https://api.invernaderos.com/api/v1/tenants/1/users/1" \
-H "Authorization: Bearer YOUR_TOKEN"
Delete a user from a tenant.
Path Parameters
Unique identifier of the tenant
Unique identifier of the user to delete
Response
204 - No Content
404 - Not Found
User Roles and Permissions
Administrator - Full access to all featuresPermissions:
Create, read, update, delete tenants
Manage all greenhouses
Manage all users (including other admins)
View and resolve all alerts
Configure system settings
Access audit logs
Operator - Manage greenhouse operationsPermissions:
View tenant information (read-only)
Manage greenhouses (create, update)
View and manage sensors/actuators
View and resolve alerts
Cannot manage users
Cannot delete greenhouses
Viewer - Read-only accessPermissions:
View tenant information
View greenhouses and sensor data
View alerts (cannot resolve)
Cannot create, update, or delete anything
Cannot manage users
User Activation and Deactivation
Users can be activated or deactivated without deleting them:
Deactivate User
curl -X PUT "https://api.invernaderos.com/api/v1/tenants/1/users/1" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"isActive": false}'
Effect:
User cannot log in
Existing sessions are invalidated
User data and history are preserved
Can be reactivated later
Reactivate User
curl -X PUT "https://api.invernaderos.com/api/v1/tenants/1/users/1" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"isActive": true}'
Effect:
User can log in again
All previous data and permissions are restored