Skip to main content

Listing all tenants and apps

List all tenants for an app

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

List all apps in a SuperTokens core

This 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.

curl --location --request GET '<CORE_API_ENDPOINT>/recipe/multitenancy/app/list/v2' \
--header 'api-key: <YOUR_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 '<CORE_API_ENDPOINT>/recipe/multitenancy/app/list' \
--header 'api-key: <YOUR_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": {...}
}]
}]
}