Tenants API
Introduction
In B2B SaaS applications, all users are usually grouped into tenants. Each of your business customers is represented as a tenant. The related users and all the data are fully isolated. Please refer to the multi-tenancy feature guide for more information and instructions.
Mutations
createTenant()
You can create a new tenant by setting a name and reference. The API documentation for createTenant() is here (opens in a new tab).
The returned id is needed when you assign tenants to users by using createUser() or updateUser().
const tenantId = await client.asSuperAdmin().createTenant({ tenant: { 
    name: 'Car Rental',
    reference: "car-rental" 
  } 
});| Parameter | Type | Description | 
|---|---|---|
tenant:name | string | The tenant name | 
tenant:reference | string | The tenant reference | 
updateTenant()
The updateTenant() API method works the same way as createTenant(). This API will update the tenant data. Read here (opens in a new tab) for the API documentation.
await roqClient.asSuperAdmin().updateTenant({
  id: "tenant_id_is_here",
  tenant: {
    name: "Truck Rental",
    reference: "truck-rental"
  }
})| Parameter | Type | Description | 
|---|---|---|
id | uuid | The tenant id | 
tenant:name | string | The tenant name | 
tenant:reference | string | The tenant reference | 
Queries
tenants()
Get the tenants data. For the documentation of this API can be found here (opens in a new tab).
All GraphQL query parameters can be applied here to narrow down the results.
const tenantsData = await client.asSuperAdmin().tenants({
  limit: 3
});tenant()
Retrieve tenant data using its ID. Refer to the tenant() API documentation here (opens in a new tab).
await client.asSuperAdmin().tenant({ 
  id: "tenant_id_is_here"
});| Parameter | Type | Description | 
|---|---|---|
id | uuid | The tenant id |