FluxbaseTenant
FluxbaseTenant provides multi-tenant management functionality
Example
Section titled “Example”// List tenants I have access toconst { data } = await client.tenant.listMine()
// Get tenant detailsconst { data } = await client.tenant.get('tenant-id')
// Create a tenant (instance admin only)const { data } = await client.tenant.create({ slug: 'acme-corp', name: 'Acme Corporation'})
// Assign admin to tenant (tenant admin only)await client.tenant.assignAdmin('tenant-id', { user_id: 'user-id'})Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FluxbaseTenant(
fetch):FluxbaseTenant
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fetch | FluxbaseFetch |
Returns
Section titled “Returns”FluxbaseTenant
Methods
Section titled “Methods”assignAdmin()
Section titled “assignAdmin()”assignAdmin(
tenantId,options):Promise<FluxbaseResponse<TenantAdminAssignment>>
Assign an admin to a tenant (tenant admin only)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
tenantId | string | Tenant ID |
options | AssignAdminOptions | Admin assignment options |
Returns
Section titled “Returns”Promise<FluxbaseResponse<TenantAdminAssignment>>
Promise with created assignment or error
Example
Section titled “Example”const { data, error } = await client.tenant.assignAdmin('tenant-id', { user_id: 'user-id'})create()
Section titled “create()”create(
options):Promise<FluxbaseResponse<Tenant>>
Create a new tenant (instance admin only)
This creates a new isolated database for the tenant.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | CreateTenantOptions | Tenant creation options |
Returns
Section titled “Returns”Promise<FluxbaseResponse<Tenant>>
Promise with created tenant or error
Example
Section titled “Example”const { data, error } = await client.tenant.create({ slug: 'acme-corp', name: 'Acme Corporation', metadata: { plan: 'enterprise' }})delete()
Section titled “delete()”delete(
id):Promise<FluxbaseResponse<void>>
Delete a tenant (instance admin only)
This permanently deletes the tenant’s database and all its data. Cannot delete the default tenant.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id | string | Tenant ID |
Returns
Section titled “Returns”Promise<FluxbaseResponse<void>>
Promise that resolves when deleted
Example
Section titled “Example”const { error } = await client.tenant.delete('tenant-id')get(
id):Promise<FluxbaseResponse<Tenant>>
Get a tenant by ID
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id | string | Tenant ID |
Returns
Section titled “Returns”Promise<FluxbaseResponse<Tenant>>
Promise with tenant details or error
Example
Section titled “Example”const { data, error } = await client.tenant.get('tenant-id')list()
Section titled “list()”list():
Promise<FluxbaseResponse<Tenant[]>>
List all tenants (instance admin only)
Returns
Section titled “Returns”Promise<FluxbaseResponse<Tenant[]>>
Promise with tenants list or error
Example
Section titled “Example”const { data, error } = await client.tenant.list()listAdmins()
Section titled “listAdmins()”listAdmins(
tenantId):Promise<FluxbaseResponse<TenantAdminAssignment[]>>
List admins of a tenant
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
tenantId | string | Tenant ID |
Returns
Section titled “Returns”Promise<FluxbaseResponse<TenantAdminAssignment[]>>
Promise with admin list or error
Example
Section titled “Example”const { data, error } = await client.tenant.listAdmins('tenant-id')// data: [{ id: '...', tenant_id: '...', user_id: '...', email: 'admin@example.com' }]listMine()
Section titled “listMine()”listMine():
Promise<FluxbaseResponse<TenantWithRole[]>>
List tenants the current user has access to
Returns
Section titled “Returns”Promise<FluxbaseResponse<TenantWithRole[]>>
Promise with tenants and user’s role in each
Example
Section titled “Example”const { data, error } = await client.tenant.listMine()// data: [{ id: '...', slug: 'acme', name: 'Acme', my_role: 'tenant_admin', status: 'active' }]migrate()
Section titled “migrate()”migrate(
id):Promise<FluxbaseResponse<{status:string; }>>
Migrate a tenant database to the latest schema (instance admin only)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id | string | Tenant ID |
Returns
Section titled “Returns”Promise<FluxbaseResponse<{ status: string; }>>
Promise with migration status or error
Example
Section titled “Example”const { data, error } = await client.tenant.migrate('tenant-id')// data: { status: 'migrated' }removeAdmin()
Section titled “removeAdmin()”removeAdmin(
tenantId,userId):Promise<FluxbaseResponse<void>>
Remove an admin from a tenant (tenant admin only)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
tenantId | string | Tenant ID |
userId | string | User ID |
Returns
Section titled “Returns”Promise<FluxbaseResponse<void>>
Promise that resolves when removed
Example
Section titled “Example”const { error } = await client.tenant.removeAdmin('tenant-id', 'user-id')update()
Section titled “update()”update(
id,options):Promise<FluxbaseResponse<Tenant>>
Update a tenant (tenant admin only)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id | string | Tenant ID |
options | UpdateTenantOptions | Update options |
Returns
Section titled “Returns”Promise<FluxbaseResponse<Tenant>>
Promise with updated tenant or error
Example
Section titled “Example”const { data, error } = await client.tenant.update('tenant-id', { name: 'New Name'})