HomeReference

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 name

- limit (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 Internal Admin

Retrieve details about the internal admin (MSP).

Endpoint: GET /v1/admin/tenants/internal-admin
Example Query
curl 'https://api.hatz.ai/v1/admin/tenants/internal-admin' \
  -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 HashID (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)

- package_id (optional): Package HashID (e.g., "package_xyz"). Required if template_id not provided

- template_id (optional): Tenant template HashID (e.g., "tentemplate_xyz"). Required if package_id not provided

- users (optional): Initial users for the tenant (max 1000)

- email (required): User email address

- first_name (optional): User first name

- last_name (optional): User last name

- role (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 HashID (e.g., "package_xyz"). Required if template_id not provided
      "template_id": "string",    // Optional: Template HashID (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 HashID (e.g., "tenant_abc123")

Request Body:

- beta_features (optional): Enable or disable beta features

- mfa_required (optional): Require MFA for all users in tenant

- default_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

{
  "beta_features": true,
  "mfa_required": true,
  "default_model_name": "gpt-4o"
}