fastify-xadmin
Tenants Routes
Admin REST endpoints for listing and creating tenants — GET /api/admin/tenants, POST /api/admin/tenants.
Tenants Routes
Endpoints for listing all tenants and creating new ones. Tenants represent isolated organisations or workspaces within a multi-tenant deployment.
Routes
GET /api/admin/tenants List all tenants
POST /api/admin/tenants Create a new tenant
GET /api/admin/tenants
Return all tenants with basic metadata.
Usage
const response = await fetch("/api/admin/tenants?page=1&limit=20", {
headers: { Authorization: `Bearer ${adminToken}` },
});
const { tenants, total } = await response.json();
Query Parameters
| Name | Type | Default | Description |
|---|---|---|---|
page | number | 1 | Page number (1-indexed). |
limit | number | 20 | Results per page. |
search | string | — | Filter by tenant name or slug. |
Response
{
"tenants": [
{
"id": "tnt_abc",
"slug": "acme-corp",
"name": "Acme Corp",
"userCount": 12,
"createdAt": "2025-01-15T09:00:00.000Z"
}
],
"total": 5,
"page": 1,
"limit": 20
}
POST /api/admin/tenants
Create a new tenant organisation.
Usage
const response = await fetch("/api/admin/tenants", {
method: "POST",
headers: {
Authorization: `Bearer ${adminToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
slug: "globex",
name: "Globex Corporation",
}),
});
const tenant = await response.json();
Body Fields
| Field | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | URL-safe unique identifier (e.g., "globex"). |
name | string | Yes | Display name for the tenant. |
Response
{
"id": "tnt_xyz",
"slug": "globex",
"name": "Globex Corporation",
"userCount": 0,
"createdAt": "2025-04-19T10:00:00.000Z"
}
AI Context
package: "@xenterprises/fastify-xadmin"
routes:
- GET /api/admin/tenants — paginated tenant list with optional name/slug search
- POST /api/admin/tenants — create tenant; slug must be unique
auth: all routes require the admin role set at plugin registration
See Also
- Users Routes — filter users by tenantId or move a user to a different tenant
- Audit Log — tenant creation events appear in the audit log
Stripe Management Routes
Admin Stripe endpoints for viewing and managing a customer's subscription and billing data — GET/POST /api/admin/stripe/:customerId.
Users Routes
Admin REST endpoints for listing, reading, updating, and deleting user accounts — GET /api/admin/users, GET/PATCH/DELETE /api/admin/users/:id.
