---
title: supertokens-node/recipe/multitenancy
description: References documentation for the supertokens-node/recipe/multitenancy package
sidebar:
  order: 190
---

## Classes

### default

Defined in: [recipe/multitenancy/index.ts:23](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L23)

#### Constructors

##### Constructor

```ts check=false reason="Generated API signature"
new default(): default;
```

###### Returns

[`default`](#default)

#### Properties

| Property | Modifier | Type | Default value | Defined in |
| ------ | ------ | ------ | ------ | ------ |
| <a id="member-default-init"></a> `init` | `static` | (`config?`) => [`RecipeListFunction`](types#recipelistfunction) | `Recipe.init` | [recipe/multitenancy/index.ts:24](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L24) |

#### Methods

##### associateUserToTenant()

```ts check=false reason="Generated API signature"
static associateUserToTenant(
   tenantId, 
   recipeUserId, 
   userContext?): Promise<
  | {
  status: "OK";
  wasAlreadyAssociated: boolean;
}
  | {
  status:   | "EMAIL_ALREADY_EXISTS_ERROR"
     | "UNKNOWN_USER_ID_ERROR"
     | "PHONE_NUMBER_ALREADY_EXISTS_ERROR"
     | "THIRD_PARTY_USER_ALREADY_EXISTS_ERROR";
}
  | {
  reason: string;
  status: "ASSOCIATION_NOT_ALLOWED_ERROR";
}>;
```

Defined in: [recipe/multitenancy/index.ts:124](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L124)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `recipeUserId` | [`RecipeUserId`](index#recipeuserid-1) |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `wasAlreadyAssociated`: `boolean`;
\}
  \| \{
  `status`:   \| `"EMAIL_ALREADY_EXISTS_ERROR"`
     \| `"UNKNOWN_USER_ID_ERROR"`
     \| `"PHONE_NUMBER_ALREADY_EXISTS_ERROR"`
     \| `"THIRD_PARTY_USER_ALREADY_EXISTS_ERROR"`;
\}
  \| \{
  `reason`: `string`;
  `status`: `"ASSOCIATION_NOT_ALLOWED_ERROR"`;
\}\>

##### createOrUpdateTenant()

```ts check=false reason="Generated API signature"
static createOrUpdateTenant(
   tenantId, 
   config?, 
   userContext?): Promise<{
  createdNew: boolean;
  status: "OK";
}>;
```

Defined in: [recipe/multitenancy/index.ts:26](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L26)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `config?` | \{ `coreConfig?`: \{ \[`key`: `string`\]: `any`; \}; `firstFactors?`: `string`[]; `requiredSecondaryFactors?`: `string`[]; \} |
| `config.coreConfig?` | \{ \[`key`: `string`\]: `any`; \} |
| `config.firstFactors?` | `string`[] |
| `config.requiredSecondaryFactors?` | `string`[] |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `createdNew`: `boolean`;
  `status`: `"OK"`;
\}\>

##### createOrUpdateThirdPartyConfig()

```ts check=false reason="Generated API signature"
static createOrUpdateThirdPartyConfig(
   tenantId, 
   config, 
   skipValidation?, 
   userContext?): Promise<{
  createdNew: boolean;
  status: "OK";
}>;
```

Defined in: [recipe/multitenancy/index.ts:90](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L90)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `config` | [`ProviderConfig`](recipe-thirdparty-types#providerconfig) |
| `skipValidation?` | `boolean` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `createdNew`: `boolean`;
  `status`: `"OK"`;
\}\>

##### deleteTenant()

```ts check=false reason="Generated API signature"
static deleteTenant(tenantId, userContext?): Promise<{
  didExist: boolean;
  status: "OK";
}>;
```

Defined in: [recipe/multitenancy/index.ts:46](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L46)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `didExist`: `boolean`;
  `status`: `"OK"`;
\}\>

##### deleteThirdPartyConfig()

```ts check=false reason="Generated API signature"
static deleteThirdPartyConfig(
   tenantId, 
   thirdPartyId, 
   userContext?): Promise<{
  didConfigExist: boolean;
  status: "OK";
}>;
```

Defined in: [recipe/multitenancy/index.ts:108](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L108)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `thirdPartyId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `didConfigExist`: `boolean`;
  `status`: `"OK"`;
\}\>

##### disassociateUserFromTenant()

```ts check=false reason="Generated API signature"
static disassociateUserFromTenant(
   tenantId, 
   recipeUserId, 
   userContext?): Promise<{
  status: "OK";
  wasAssociated: boolean;
}>;
```

Defined in: [recipe/multitenancy/index.ts:153](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L153)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `recipeUserId` | [`RecipeUserId`](index#recipeuserid-1) |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `status`: `"OK"`;
  `wasAssociated`: `boolean`;
\}\>

##### getTenant()

```ts check=false reason="Generated API signature"
static getTenant(tenantId, userContext?): Promise<object & TenantConfig>;
```

Defined in: [recipe/multitenancy/index.ts:60](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L60)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<`object` & [`TenantConfig`](recipe-multitenancy-types#tenantconfig)\>

##### listAllTenants()

```ts check=false reason="Generated API signature"
static listAllTenants(userContext?): Promise<{
  status: "OK";
  tenants: object & TenantConfig[];
}>;
```

Defined in: [recipe/multitenancy/index.ts:76](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L76)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `status`: `"OK"`;
  `tenants`: `object` & [`TenantConfig`](recipe-multitenancy-types#tenantconfig)[];
\}\>

## Variables

### AllowedDomainsClaim

```ts check=false reason="Generated API signature"
const AllowedDomainsClaim: AllowedDomainsClaimClass;
```

Defined in: [recipe/multitenancy/allowedDomainsClaim.ts:23](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/allowedDomainsClaim.ts#L23)

***

### associateUserToTenant()

```ts check=false reason="Generated API signature"
associateUserToTenant: (tenantId, recipeUserId, userContext?) => Promise<
  | {
  status: "OK";
  wasAlreadyAssociated: boolean;
}
  | {
  status:   | "EMAIL_ALREADY_EXISTS_ERROR"
     | "UNKNOWN_USER_ID_ERROR"
     | "PHONE_NUMBER_ALREADY_EXISTS_ERROR"
     | "THIRD_PARTY_USER_ALREADY_EXISTS_ERROR";
}
  | {
  reason: string;
  status: "ASSOCIATION_NOT_ALLOWED_ERROR";
}> = Wrapper.associateUserToTenant;
```

Defined in: [recipe/multitenancy/index.ts:180](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L180)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `recipeUserId` | [`RecipeUserId`](index#recipeuserid-1) |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `wasAlreadyAssociated`: `boolean`;
\}
  \| \{
  `status`:   \| `"EMAIL_ALREADY_EXISTS_ERROR"`
     \| `"UNKNOWN_USER_ID_ERROR"`
     \| `"PHONE_NUMBER_ALREADY_EXISTS_ERROR"`
     \| `"THIRD_PARTY_USER_ALREADY_EXISTS_ERROR"`;
\}
  \| \{
  `reason`: `string`;
  `status`: `"ASSOCIATION_NOT_ALLOWED_ERROR"`;
\}\>

***

### createOrUpdateTenant()

```ts check=false reason="Generated API signature"
createOrUpdateTenant: (tenantId, config?, userContext?) => Promise<{
  createdNew: boolean;
  status: "OK";
}> = Wrapper.createOrUpdateTenant;
```

Defined in: [recipe/multitenancy/index.ts:172](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L172)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `config?` | \{ `coreConfig?`: \{ \[`key`: `string`\]: `any`; \}; `firstFactors?`: `string`[]; `requiredSecondaryFactors?`: `string`[]; \} |
| `config.coreConfig?` | \{ \[`key`: `string`\]: `any`; \} |
| `config.firstFactors?` | `string`[] |
| `config.requiredSecondaryFactors?` | `string`[] |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `createdNew`: `boolean`;
  `status`: `"OK"`;
\}\>

***

### createOrUpdateThirdPartyConfig()

```ts check=false reason="Generated API signature"
createOrUpdateThirdPartyConfig: (tenantId, config, skipValidation?, userContext?) => Promise<{
  createdNew: boolean;
  status: "OK";
}> = Wrapper.createOrUpdateThirdPartyConfig;
```

Defined in: [recipe/multitenancy/index.ts:177](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L177)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `config` | [`ProviderConfig`](recipe-thirdparty-types#providerconfig) |
| `skipValidation?` | `boolean` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `createdNew`: `boolean`;
  `status`: `"OK"`;
\}\>

***

### deleteTenant()

```ts check=false reason="Generated API signature"
deleteTenant: (tenantId, userContext?) => Promise<{
  didExist: boolean;
  status: "OK";
}> = Wrapper.deleteTenant;
```

Defined in: [recipe/multitenancy/index.ts:173](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L173)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `didExist`: `boolean`;
  `status`: `"OK"`;
\}\>

***

### deleteThirdPartyConfig()

```ts check=false reason="Generated API signature"
deleteThirdPartyConfig: (tenantId, thirdPartyId, userContext?) => Promise<{
  didConfigExist: boolean;
  status: "OK";
}> = Wrapper.deleteThirdPartyConfig;
```

Defined in: [recipe/multitenancy/index.ts:178](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L178)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `thirdPartyId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `didConfigExist`: `boolean`;
  `status`: `"OK"`;
\}\>

***

### disassociateUserFromTenant()

```ts check=false reason="Generated API signature"
disassociateUserFromTenant: (tenantId, recipeUserId, userContext?) => Promise<{
  status: "OK";
  wasAssociated: boolean;
}> = Wrapper.disassociateUserFromTenant;
```

Defined in: [recipe/multitenancy/index.ts:181](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L181)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `recipeUserId` | [`RecipeUserId`](index#recipeuserid-1) |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `status`: `"OK"`;
  `wasAssociated`: `boolean`;
\}\>

***

### getTenant()

```ts check=false reason="Generated API signature"
getTenant: (tenantId, userContext?) => Promise<object & TenantConfig> = Wrapper.getTenant;
```

Defined in: [recipe/multitenancy/index.ts:174](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L174)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<`object` & [`TenantConfig`](recipe-multitenancy-types#tenantconfig)\>

***

### init()

```ts check=false reason="Generated API signature"
init: (config?) => RecipeListFunction = Wrapper.init;
```

Defined in: [recipe/multitenancy/index.ts:170](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L170)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `config?` | [`TypeInput`](recipe-multitenancy-types#typeinput) |

#### Returns

[`RecipeListFunction`](types#recipelistfunction)

***

### listAllTenants()

```ts check=false reason="Generated API signature"
listAllTenants: (userContext?) => Promise<{
  status: "OK";
  tenants: object & TenantConfig[];
}> = Wrapper.listAllTenants;
```

Defined in: [recipe/multitenancy/index.ts:175](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/multitenancy/index.ts#L175)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `status`: `"OK"`;
  `tenants`: `object` & [`TenantConfig`](recipe-multitenancy-types#tenantconfig)[];
\}\>

## References

### APIInterface

Re-exports [APIInterface](recipe-multitenancy-types#apiinterface)

***

### APIOptions

Re-exports [APIOptions](recipe-multitenancy-types#apioptions)

***

### RecipeInterface

Re-exports [RecipeInterface](recipe-multitenancy-types#recipeinterface)
