Skip to main content

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

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

tenantId
long
required
Unique identifier of the tenant

Response

id
long
Unique identifier of the user
code
string
Unique readable code (e.g., “USR-00001”)
username
string
Username for login
email
string
User’s email address
role
string
User role (ADMIN, OPERATOR, VIEWER)
tenantId
long
ID of the tenant the user belongs to
isActive
boolean
Whether the user account is active
lastLogin
timestamp
Last login timestamp (ISO 8601)
createdAt
timestamp
Creation timestamp (ISO 8601)
updatedAt
timestamp
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

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

tenantId
long
required
Unique identifier of the tenant
userId
long
required
Unique identifier of the user

Response

{
  "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

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

tenantId
long
required
Unique identifier of the tenant

Request Body

username
string
required
Username for login (must be unique)
email
string
required
Email address (must be valid and unique)
passwordRaw
string
required
User’s password (will be hashed before storage)
role
string
required
User role: ADMIN, OPERATOR, or VIEWER
isActive
boolean
default:"true"
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

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

tenantId
long
required
Unique identifier of the tenant
userId
long
required
Unique identifier of the user to update

Request Body

All fields are optional. Only provided fields will be updated.
username
string
Username for login
email
string
Email address
passwordRaw
string
New password (if changing)
role
string
User role (ADMIN, OPERATOR, VIEWER)
isActive
boolean
Whether the user account is active

Response

{
  "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

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

tenantId
long
required
Unique identifier of the tenant
userId
long
required
Unique identifier of the user to delete

Response

# Successfully deleted

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

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

Build docs developers (and LLMs) love