Tenants API
Create and Manage tenants via the Semaphor Management API
Overview
The Tenants API allows you to create, retrieve, update, and delete tenants programmatically. This API is designed for organization administrators to manage tenant organizations within their system.
Base path:
All endpoints require authentication and organization-level permissions.
Example: Create a Tenant via API
1. Get a project token
2. Create a tenant
Expected Response:
List Tenants
GET /tenants
- Returns a list of tenants with pagination and filtering options.
- Only organization users can access this endpoint.
Query Parameters:
search
(optional): Search by tenant namelimit
(optional): Number of results per page (default: 500)offset
(optional): Number of results to skip (default: 0)
Example Request:
Example Response:
Create Tenant
POST /tenants
- Creates a new tenant within the organization.
- Only organization users can create tenants.
Request Body:
Required Fields:
name
: Tenant name (must be unique within the organization)
Optional Fields:
defaultOwnerId
: ID of the tenant user who will be the default owner
Example Request:
Example Response:
Get Tenant by ID
GET /tenants/:id
- Returns details for a specific tenant, including user count and default owner information.
- Only organization users can access this endpoint.
Example Request:
Example Response:
Update Tenant
PUT /tenants/:id
- Updates an existing tenant's information.
- Only organization users can update tenants.
Request Body:
All fields are optional. Only provided fields will be updated.
Example Request:
Example Response:
Delete Tenant
DELETE /tenants/:id
- Deletes a tenant.
- Only organization users can delete tenants.
- Cannot delete a tenant that has active users.
Example Request:
Example Response:
Tenant Management
Default Owner
Each tenant has a default owner who is responsible for the tenant:
- The default owner is a tenant user who has special privileges
- Default owners cannot be deleted from the tenant
- You can change the default owner by updating the tenant
User Count
The API provides user count information for each tenant:
- Shows the total number of active tenant users
- Helps with tenant management and capacity planning
- Updated automatically when users are added or removed
Error Handling
Common error responses:
400 Bad Request:
401 Unauthorized:
403 Forbidden:
404 Not Found:
409 Conflict:
409 Conflict (Delete with Users):
Notes
- All endpoints require authentication (Bearer token)
- Only organization users can manage tenants
- Tenant names must be unique within each organization
- Tenants cannot be deleted if they have active users
- The API automatically validates required fields
- All timestamps are returned in ISO 8601 format
- Default owners have special privileges and cannot be deleted
- User counts are automatically maintained and updated