Overview
Tenant Users represent the relationship between global SaaS users and specific tenant organizations. A single user can be assigned to multiple tenants with different roles in each. This system enables:- Multi-tenant user access with role-based permissions
- Plan-based user limits and validation
- Automatic synchronization between global and tenant-local user databases
- Role assignment per tenant (Admin, Cashier, Warehouse, etc.)
User Synchronization
When users are assigned to a tenant, the system automatically:- Creates or updates the user in the global
saas_userstable - Links the user to the tenant in the
tenant_userstable - Synchronizes the user to the tenant’s local schema
userstable - Assigns the appropriate role based on the tenant’s role configuration
Assign User to Tenant
Assigns a user to a tenant organization. If the user doesn’t exist globally, this endpoint creates a new user account. The endpoint validates plan limits and synchronizes the user to the tenant’s local database.Headers
Bearer token for authenticated superuser
Path Parameters
The unique identifier of the tenant to assign the user to
Body
User’s email address (used for authentication and identification)
Password for new users. Required if the user doesn’t exist globally. Ignored for existing users.
User’s full name
Role to assign within this tenant (e.g., “ADMINISTRADOR”, “CAJERO”, “BODEGUERO”)
Response
Unique tenant-user assignment identifier
The tenant ID this assignment belongs to
The global user ID
The role assigned to this user within the tenant
Whether this user assignment is currently active
Nested user object containing:
id(integer): User’s global IDemail(string): User’s email addressfull_name(string): User’s full nameis_active(boolean): Whether the user account is activeis_superuser(boolean): Whether the user is a platform superuser
Error Responses
400 Bad Request - User Limit Exceeded
Returned when the tenant has reached its maximum user limit based on the subscription plan.
400 Bad Request - Password Required
Returned when creating a new user without providing a password.
400 Bad Request - User Already Assigned
Returned when the user is already assigned to this tenant.
403 Forbidden
Returned when the authenticated user is not a superuser.
404 Not Found
Returned when the specified tenant does not exist.
List Tenant Users
Retrieves all users assigned to a specific tenant, including their roles and status.Headers
Bearer token for authenticated superuser
Path Parameters
The unique identifier of the tenant
Response
Returns an array of tenant-user assignment objects with the same structure as the Assign User response.Error Responses
403 Forbidden
Returned when the authenticated user is not a superuser.
Update Tenant User
Updates a user’s role, status, password, or name within a tenant. Changes are automatically synchronized to the tenant’s local database schema.Headers
Bearer token for authenticated superuser
Path Parameters
The unique identifier of the tenant
The global user ID to update
Body
All fields are optional. Only include fields you want to update.Updated role for this user within the tenant
Whether this user assignment should be active
New password for the user (updates globally, not tenant-specific)
Updated full name for the user (updates globally, not tenant-specific)
Response
Returns the updated tenant-user assignment object with the same structure as the Assign User response.Error Responses
403 Forbidden
Returned when the authenticated user is not a superuser.
404 Not Found
Returned when the tenant-user assignment does not exist.
Plan Limits and Validation
User assignments are subject to plan-based limits:Max Users Calculation
The system determines the maximum allowed users using this priority:- Tenant Override: If
max_users_overrideis set on the tenant, use that value - Plan Limit: Otherwise, use the plan’s
max_usersvalue - Default: If no plan is assigned, default to 1 user
Validation Rules
- Only active tenant users count toward the limit
- Deactivated users (
is_active = false) do not count - The limit is checked before creating new user assignments
- Superusers can set custom limits via
max_users_override
Example Scenarios
Scenario 1: Plan Limit- Tenant has plan with
max_users = 3 - No override set
- Can assign up to 3 active users
- Tenant has plan with
max_users = 3 max_users_override = 10is set- Can assign up to 10 active users
- Limit is 3 users
- 3 active users + 2 deactivated users = 3 counted
- Can still assign more users (deactivated don’t count)