Admin - Tenant
Manage tenants under your Admin account. View tenant details, usage statistics, and list users within each tenant.
List Tenants
Get all tenants.
Endpoint:
GET /v1/admin/tenants
Query Parameters:
name(optional): Filter by exact tenant namelimit(optional): Number of results (1-100, default: 20)offset(optional): Pagination offset (default: 0)
Example Query
curl 'https://api.hatz.ai/v1/admin/tenants?name=Acme%20Corporation' \
-H 'X-API-Key: $HATZ_API_KEY' \
-H 'Content-Type: application/json' \
Response
[
{
"id": "tenant_abc123",
"name": "Acme Corporation",
"primary_package_name": "Professional",
"additional_package_names": ["1500 Extra Credits"],
"user_count": 25,
"status": "active",
"created_at": "2024-01-15T09:00:00Z",
"total_credits_used": 15000,
"total_credit_limit": 50000,
"tenant_config": {
"beta_features": false,
"mfa_required": false,
"default_model_name": "gpt-4o"
}
}
]
Get own MSP
Retrieve details about the internal admin (MSP).
Endpoint:
GET /v1/admin/tenants/msp
Example Query
curl 'https://api.hatz.ai/v1/admin/tenants/msp' \
-H 'X-API-Key: $HATZ_API_KEY' \
-H 'Content-Type: application/json' \
Response
{
"name": "Internal Admin MSP",
"primary_package_name": "Enterprise",
"total_credits_used": 125000,
"total_credit_limit": 500000,
"user_count": 15,
"created_at": "2023-01-01T00:00:00Z"
}
Get Tenant Details
Retrieve details for a specific tenant by ID.
Endpoint:
GET /v1/admin/tenants/{tenant_id}
Path Parameters:
tenant_id: Tenant ID (e.g., "tenant_abc123")
Example Query
curl 'https://api.hatz.ai/v1/admin/tenants/tenant_abc123' \
-H 'X-API-Key: $HATZ_API_KEY' \
-H 'Content-Type: application/json' \
Response
{
"id": "tenant_abc123",
"name": "Acme Corporation",
"primary_package_name": "Professional",
"additional_package_names": [],
"user_count": 25,
"status": "Active",
"created_at": "2024-01-15T09:00:00Z",
"total_credits_used": 15000,
"total_credit_limit": 50000,
"tenant_config": {
"beta_features": false,
"mfa_required": true,
"default_model_name": "gpt-4o"
},
"disabled_model_names": ["claude-3-opus"]
}
Get Tenant Users
Get all users belonging to a specific tenant.
Endpoint:
GET /v1/admin/tenants/{tenant_id}/users
Path Parameters:
tenant_id(required): Tenant ID (e.g., "tenant_abc123")
Query Parameters:
limit(optional): Number of results (1-1000, default: 100)offset(optional): Pagination offset (default: 0)
Example Request
curl 'https://api.hatz.ai/v1/admin/tenants/tenant_abc123/users?limit=50&offset=0' \
-H 'X-API-Key: $HATZ_API_KEY' \
-H 'Content-Type: application/json' \
Response
[
{
"id": "user_xyz789",
"email": "john.doe@acme.com",
"first_name": "John",
"last_name": "Doe",
"tenant_id": "tenant_abc123",
"role_name": "admin",
"last_sign_in_at": "2024-06-15T14:30:00Z"
},
{
"id": "user_abc456",
"email": "jane.smith@acme.com",
"first_name": "Jane",
"last_name": "Smith",
"tenant_id": "tenant_abc123",
"role_name": "member",
"last_sign_in_at": "2024-06-14T09:15:00Z"
}
]
Create Tenants
Create one or more tenants with optional users.
Endpoint:
POST /v1/admin/tenants
Request Body:
tenants(required): List of tenants to create (1-100)tenant_name(required): Tenant name (1-255 characters). Must be globally unique across all entities (not MSP-scoped). This is enforced server-side increate_tenantandcreate_tenant_without_package; a request will fail if the name already exists.package_id(optional): Package ID (e.g., "package_xyz"). Required iftemplate_idnot providedtemplate_id(optional): Tenant template ID (e.g., "tentemplate_xyz"). Required ifpackage_idnot providedusers(optional): Initial users for the tenant (max 1000)email(required): User email addressfirst_name(optional): User first namelast_name(optional): User last namerole(optional): User role in the organization
Note - there must be an existing unassigned package in the account that matches the type specified by the incoming package or template ID in order to create the new tenant and assign a package to them.
Request
{
"tenants": [ // Required: Array of tenants to create (1-100)
{
"tenant_name": "string", // Required: Tenant name (1-255 characters)
"package_id": "string", // Optional: Package ID (e.g., "package_xyz"). Required if template_id not provided
"template_id": "string", // Optional: Template ID (e.g., "tentemplate_xyz"). Required if package_id not provided
}
]
}
Example Request
curl -X POST 'https://api.hatz.ai/v1/admin/tenants' \
-H 'X-API-Key: $HATZ_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"tenants": [
{
"tenant_name": "Acme Corporation",
"package_id": "package_abc123",
"users": [
{
"email": "admin@acme.com",
"first_name": "John",
"last_name": "Doe",
"role": "admin"
}
]
}
]
}'
Response
{
"message": "Successfully created 1 tenants",
"total_tenants_created": 1,
"total_tenants_failed": 0,
"tenants": [
{
"tenant_name": "Acme Corporation",
"tenant_id": "tenant_def456",
"success": true,
"error": null,
"total_new_users_created": 1,
"total_new_users_failed": 0,
"new_users_failed_emails": [],
"purchase_occurred": false
}
]
}
Update Tenant Configuration
Update tenant configuration settings including beta features, MFA requirements, and default AI model.
Endpoint:
PATCH /v1/admin/tenants/{tenant_id}/config
Path Parameters:
tenant_id(required): Tenant ID (e.g., "tenant_abc123")
Request Body:
beta_features(optional): Enable or disable beta featuresmfa_required(optional): Require MFA for all users in tenantdefault_model_name(optional): Default AI model name (e.g., "gpt-4o"). Set to empty string to clear.
Example Request
curl -X PATCH 'https://api.hatz.ai/v1/admin/tenants/tenant_abc123/config' \
-H 'X-API-Key: $HATZ_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"beta_features": true,
"mfa_required": true,
"default_model_name": "gpt-4o"
}'
### Response
```json
{
"beta_features": true,
"mfa_required": true,
"default_model_name": "gpt-4o"
}