Paid Feature
This is a paid feature.
For self hosted users, Sign up to get a license key and follow the instructions sent to you by email. Creation of tenants is free on the dev license key.
This feature is already enabled for managed service users. Creation of additional tenant is free on the provided development environment.
Listing all tenants and apps
#
List all tenants for an app- NodeJS
- GoLang
- Python
- cURL
Important
import Multitenancy from "supertokens-node/recipe/multitenancy";
async function listAllTenants() {
let resp = await Multitenancy.listAllTenants();
let tenants = resp.tenants;
tenants.forEach(tenant => {
let coreConfig = tenant.coreConfig;
let firstFactors = tenant.firstFactors;
let configuredThirdPartyProviders = tenant.thirdParty.providers;
});
}
The value of firstFactors
can be as follows:
undefined
: All login methods are enabled in the core, any auth recipe initialised in the backend SDK will work[]
(empty array): No login methods are enabled for the tenant- a non-empty array: Only the login methods in the array are enabled for the tenant
import (
"fmt"
"github.com/supertokens/supertokens-golang/recipe/multitenancy"
)
func main() {
resp, err := multitenancy.ListAllTenants()
if err != nil {
// handle error
}
for i := 0; i < len(resp.OK.Tenants); i++ {
currTenant := resp.OK.Tenants[i]
coreConfig := currTenant.CoreConfig;
fmt.Println(coreConfig)
isEmailPasswordLoginEnabled := currTenant.EmailPassword.Enabled;
isThirdPartyLoginEnabled := currTenant.ThirdParty.Enabled;
isPasswordlessLoginEnabled := currTenant.Passwordless.Enabled;
configuredThirdPartyProviders := currTenant.ThirdParty.Providers;
if isEmailPasswordLoginEnabled {
// Tenant has email password login enabled
}
if isThirdPartyLoginEnabled {
// Tenant has third party login enabled
fmt.Println(configuredThirdPartyProviders)
}
if isPasswordlessLoginEnabled {
// Tenant has passwordless login enabled
}
}
}
- Asyncio
- Syncio
from supertokens_python.recipe.multitenancy.asyncio import list_all_tenants
async def some_func():
response = await list_all_tenants()
if response.status != "OK":
print("Handle error")
return
for tenant in response.tenants:
core_config = tenant.core_config
first_factors = tenant.first_factors
configured_third_party_providers = tenant.third_party_providers
print(core_config)
print(f"First factors: {first_factors}")
print(f"Configured third party providers: {configured_third_party_providers}")
from supertokens_python.recipe.multitenancy.syncio import list_all_tenants
def some_func():
response = list_all_tenants()
if response.status != "OK":
print("Handle error")
return
for tenant in response.tenants:
core_config = tenant.core_config
first_factors = tenant.first_factors
configured_third_party_providers = tenant.third_party_providers
print(core_config)
print(f"First factors: {first_factors}")
print(f"Configured third party providers: {configured_third_party_providers}")
- Single app setup
- Multi app setup
- Core version >= 9.1.0
- Core version <= 9.0.2
curl --location --request GET '/recipe/multitenancy/tenant/list/v2' \
--header 'api-key: ' \
--header 'Content-Type: application/json'
You will get the following JSON output:
{
"status": "OK",
"tenants": [{
"tenantId": "customer1",
"thirdParty": {
"providers": [...]
},
"coreConfig": {...},
"firstFactors": [...]
}]
}
The value of firstFactors
can be as follows:
undefined
: All login methods are enabled in the core, any auth recipe initialised in the backend SDK will work[]
(empty array): No login methods are enabled for the tenant- a non-empty array: Only the login methods in the array are enabled for the tenant
curl --location --request GET '/recipe/multitenancy/tenant/list' \
--header 'api-key: ' \
--header 'Content-Type: application/json'
You will get the following JSON output:
{
"status": "OK",
"tenants": [{
"tenantId": "customer1",
"emailPassword": {
"enabled": true
},
"thirdParty": {
"enabled": true,
"providers": [...]
},
"passwordless": {
"enabled": true
},
"coreConfig": {...}
}]
}
- Core version >= 9.1.0
- Core version <= 9.0.2
curl --location --request GET '/recipe/multitenancy/tenant/list/v2' \
--header 'api-key: ' \
--header 'Content-Type: application/json'
You will get the following JSON output:
{
"status": "OK",
"tenants": [{
"tenantId": "customer1",
"thirdParty": {
"providers": [...]
},
"coreConfig": {...},
"firstFactors": [...]
}]
}
The value of firstFactors
can be as follows:
undefined
: All login methods are enabled in the core, any auth recipe initialised in the backend SDK will work[]
(empty array): No login methods are enabled for the tenant- a non-empty array: Only the login methods in the array are enabled for the tenant
curl --location --request GET '/recipe/multitenancy/tenant/list' \
--header 'api-key: ' \
--header 'Content-Type: application/json'
You will get the following JSON output:
{
"status": "OK",
"tenants": [{
"tenantId": "customer1",
"emailPassword": {
"enabled": true
},
"thirdParty": {
"enabled": true,
"providers": [...]
},
"passwordless": {
"enabled": true
},
"coreConfig": {...}
}]
}
#
List all apps in a SuperTokens coreThis can only be done via a cURL command. There is no helper function for this in our backend SDKs since our backend SDKs are per app anyway.
- Core version >= 9.1.0
- Core version <= 9.0.2
curl --location --request GET '/recipe/multitenancy/app/list/v2' \
--header 'api-key: ' \
--header 'Content-Type: application/json'
You will get the following JSON output:
{
"status": "OK",
"apps": [{
"appId": "app1",
"tenants": [{
"tenantId": "customer1",
"thirdParty": {
"providers": [...]
},
"coreConfig": {...},
"firstFactors": [...]
}]
}]
}
curl --location --request GET '/recipe/multitenancy/app/list' \
--header 'api-key: ' \
--header 'Content-Type: application/json'
You will get the following JSON output:
{
"status": "OK",
"apps": [{
"appId": "app1",
"tenants": [{
"tenantId": "customer1",
"emailPassword": {
"enabled": true
},
"thirdParty": {
"enabled": true,
"providers": [...]
},
"passwordless": {
"enabled": true
},
"coreConfig": {...}
}]
}]
}