WHAT YOU'LL LEARN
  • How to access the Tenant Manager SDK?
  • How to create and install new tenants?
  • How to disable and enable existing tenants?
  • How to handle tenant management errors?

Overview
anchor

The TenantManagerSdk provides methods for creating, installing, disabling, and enabling tenants programmatically. Access it via the tenantManager namespace on your Webiny SDK instance. Creating a new tenant requires two steps: createTenant() to register the tenant, then installTenant() to provision its resources and configurations.

All tenant management operations require an API key with tenant manager permissions.

Class Reference
anchor

TenantManagerSdk
anchor

The Tenant Manager SDK is accessed via sdk.tenantManager on a Webiny instance:

Methods
anchor

createTenant
anchor

Creates a new tenant in the system. Returns the tenant ID on success.

Parameters:

NameTypeRequiredDescription
paramsCreateTenantParamsYesTenant creation parameters
params.dataCreateTenantInputYesTenant data
params.data.idstringNoCustom tenant ID (generated if omitted)
params.data.namestringYesTenant name
params.data.descriptionstringNoTenant description

Returns:

Result<boolean, HttpError | GraphQLError | NetworkError> - Success returns true, failure returns error with message and code.

Example:

installTenant
anchor

Installs and provisions a tenant with default settings and configurations. Must be called after createTenant() before the tenant is usable.

Parameters:

NameTypeRequiredDescription
paramsInstallTenantParamsYesInstallation parameters
params.tenantIdstringYesID of the tenant to install

Returns:

Result<boolean, HttpError | GraphQLError | NetworkError> - Success returns true, failure returns error with message and code.

Example:

disableTenant
anchor

Disables a tenant, preventing access to its resources. Disabled tenants cannot be accessed until re-enabled.

Parameters:

NameTypeRequiredDescription
paramsDisableTenantParamsYesDisable parameters
params.tenantIdstringYesID of the tenant to disable

Returns:

Result<boolean, HttpError | GraphQLError | NetworkError> - Success returns true, failure returns error with message and code.

Example:

enableTenant
anchor

Re-enables a previously disabled tenant, restoring access to its resources.

Parameters:

NameTypeRequiredDescription
paramsEnableTenantParamsYesEnable parameters
params.tenantIdstringYesID of the tenant to enable

Returns:

Result<boolean, HttpError | GraphQLError | NetworkError> - Success returns true, failure returns error with message and code.

Example:

Error Handling
anchor

All tenant manager methods return a Result type. Check for errors before accessing the value:

Common error scenarios:

  • Permission denied (API key lacks tenant manager permissions)
  • Tenant already exists (duplicate tenant ID)
  • Tenant not found (invalid tenant ID)
  • Network errors (API unreachable)

Examples
anchor

Creating and Installing a New Tenant
anchor

The complete flow for provisioning a new tenant requires two steps:

Disabling and Enabling a Tenant
anchor

Error Handling Pattern
anchor