---
title: "@supertokens-plugins/tenants-nodejs"
description: "Public root exports for @supertokens-plugins/tenants-nodejs 0.2.0."
---

**Package version:** `0.2.0`

Generated from the packed release's root declaration, `./dist/index.d.ts`. Only exports reachable from that root are
listed. See the [immutable release source](https://github.com/supertokens/supertokens-plugins/blob/%40supertokens-plugins%2Ftenants-nodejs%400.2.0/packages/tenants-nodejs/src/index.ts).

:::caution
This release's declaration graph imports unpublished workspace modules (`@shared/js`, `@shared/nodejs`, `@shared/tenants`). The generator detected these imports from the packed declaration graph and strict compiler diagnostics. This upstream packaging defect cannot be fixed by the reference generator; do not enable `skipLibCheck` to hide it.
:::

## Public root exports

| Export | Kind |
| --- | --- |
| `assignAdminToUserInTenant` | Constant |
| `assignRoleToUserInTenant` | Constant |
| `AssociateAllLoginMethodsOfUserWithTenant` | Type |
| `default` | Constant |
| `GetAppUrl` | Type |
| `GetUserIdsInTenantWithRole` | Type |
| `init` | Constant |
| `PLUGIN_ID` | Constant |
| `PluginEmailDeliveryInput` | Type |
| `PluginSMTPService` | Class |
| `SendPluginEmail` | Type |
| `SuperTokensPluginTenantPluginConfig` | Type |

## `assignAdminToUserInTenant`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
declare const assignAdminToUserInTenant: (tenantId: string, userId: string) => Promise<void>;
```

## `assignRoleToUserInTenant`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
declare const assignRoleToUserInTenant: (tenantId: string, userId: string, role: string) => Promise<void>;
```

## `AssociateAllLoginMethodsOfUserWithTenant`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
import { LoginMethod } from 'supertokens-node/lib/build/user';
type AssociateAllLoginMethodsOfUserWithTenant = (tenantId: string, userId: string, loginMethodFilter?: (loginMethod: LoginMethod) => boolean) => Promise<void>;
```

## `default`

Published from the emitted `_default` declaration.

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
import * as _shared_js from '@shared/js';
import * as supertokens_node from 'supertokens-node';
declare const _default: {
    init: (config?: (SuperTokensPluginTenantPluginConfig & {
        override?: ((oI: _shared_js.OverridableFunctions<OverrideableTenantFunctionImplementation>) => _shared_js.OverridableFunctions<OverrideableTenantFunctionImplementation>) | undefined;
    }) | undefined) => supertokens_node.SuperTokensPlugin;
    SMTPService: typeof PluginSMTPService;
};
```

## `GetAppUrl`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
import { User, UserContext, NormalisedAppinfo, SuperTokensPlugin } from 'supertokens-node/types';
import { BaseRequest } from 'supertokens-node/lib/build/framework/index';
type GetAppUrl = (appInfo: NormalisedAppinfo, request: BaseRequest | undefined, userContext: UserContext) => string;
```

## `GetUserIdsInTenantWithRole`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
type GetUserIdsInTenantWithRole = (tenantId: string, role: string) => Promise<string[]>;
```

## `init`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
import * as _shared_js from '@shared/js';
import { User, UserContext, NormalisedAppinfo, SuperTokensPlugin } from 'supertokens-node/types';
declare const init: (config?: (SuperTokensPluginTenantPluginConfig & {
    override?: ((oI: _shared_js.OverridableFunctions<OverrideableTenantFunctionImplementation>) => _shared_js.OverridableFunctions<OverrideableTenantFunctionImplementation>) | undefined;
}) | undefined) => SuperTokensPlugin;
```

## `PLUGIN_ID`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
declare const PLUGIN_ID = "supertokens-plugin-tenants";
```

## `PluginEmailDeliveryInput`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
type PluginEmailDeliveryInput = {
    type: "TENANT_REQUEST_APPROVAL";
    email: string;
    tenantId: string;
    senderEmail: string;
    customData?: Record<string, any>;
    appUrl: string;
} | {
    type: "TENANT_CREATE_APPROVAL";
    email: string;
    tenantId: string;
    creatorEmail: string;
    customData?: Record<string, any>;
    appUrl: string;
};
```

## `PluginSMTPService`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
import { User, UserContext, NormalisedAppinfo, SuperTokensPlugin } from 'supertokens-node/types';
declare class PluginSMTPService implements EmailDeliveryInterface<PluginEmailDeliveryInput> {
    constructor(config: {
        smtpSettings: {
            host: string;
            port: number;
            secure?: boolean;
            authUsername?: string;
            password: string;
            from: {
                name: string;
                email: string;
            };
        };
    });
    sendEmail: (input: PluginEmailDeliveryInput & {
        userContext: UserContext;
    }) => Promise<void>;
}
```

## `SendPluginEmail`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
import { User, UserContext, NormalisedAppinfo, SuperTokensPlugin } from 'supertokens-node/types';
type SendPluginEmail = (input: PluginEmailDeliveryInput, userContext: UserContext) => Promise<void>;
```

## `SuperTokensPluginTenantPluginConfig`

Root export:

```ts check=false reason="Generated API signature"
export { type AssociateAllLoginMethodsOfUserWithTenant, type GetAppUrl, type GetUserIdsInTenantWithRole, PLUGIN_ID, type PluginEmailDeliveryInput, PluginSMTPService, type SendPluginEmail, type SuperTokensPluginTenantPluginConfig, assignAdminToUserInTenant, assignRoleToUserInTenant, _default as default, init };
```

Resolved declaration:

```ts check=false reason="Generated API signature"
import { EmailDeliveryInterface } from 'supertokens-node/lib/build/ingredients/emaildelivery/types';
type SuperTokensPluginTenantPluginConfig = {
    requireNonPublicTenantAssociation?: boolean;
    requireTenantCreationRequestApproval?: boolean;
    enableTenantListAPI?: boolean;
    createRolesOnInit?: boolean;
    allowPublicTenantAccess?: boolean;
    emailDelivery?: {
        service?: EmailDeliveryInterface<PluginEmailDeliveryInput>;
        override?: (originalImplementation: EmailDeliveryInterface<PluginEmailDeliveryInput>) => EmailDeliveryInterface<PluginEmailDeliveryInput>;
    };
};
```

## Required signature types

These declarations are not additional package-root exports. They are included because the public signatures above depend on them.

### `ErrorResponse`

```ts check=false reason="Generated API signature"
type ErrorResponse = {
    status: "ERROR";
    message: string;
};
```

### `MetadataType`

```ts check=false reason="Generated API signature"
import { pluginUserMetadata } from '@shared/nodejs';
type MetadataType = ReturnType<typeof pluginUserMetadata<TenantMetadata>>;
```

### `OverrideableTenantFunctionImplementation`

```ts check=false reason="Generated API signature"
import { SessionContainerInterface } from 'supertokens-node/recipe/session/types';
import { TenantList, TenantCreationRequest, InviteeDetails, TenantCreationRequestWithUser } from '@shared/tenants';
import { User, UserContext, NormalisedAppinfo, SuperTokensPlugin } from 'supertokens-node/types';
type OverrideableTenantFunctionImplementation = {
    getTenants: (session: SessionContainerInterface | string) => Promise<({
        status: "OK";
    } & TenantList) | ErrorResponse>;
    isAllowedToJoinTenant: (targetUser: User, session: SessionContainerInterface) => Promise<boolean>;
    isAllowedToCreateTenant: (session: SessionContainerInterface) => Promise<boolean>;
    doesTenantCreationRequireApproval: (session: SessionContainerInterface) => Promise<boolean>;
    canCreateInvitation: (email: string, role: string, tenantId: string, session: SessionContainerInterface) => Promise<boolean>;
    canApproveJoinRequest: (targetUser: User, tenantId: string, session: SessionContainerInterface) => Promise<boolean>;
    canApproveTenantCreationRequest: (targetUser: User, creationRequest: TenantCreationRequest, session: SessionContainerInterface) => Promise<boolean>;
    canRemoveTargetUserFromTenant: (targetUser: User, tenantId: string, session: SessionContainerInterface) => Promise<boolean>;
    createTenantAndAssignAdmin: (tenantDetails: {
        name: string;
        firstFactors?: string[] | null;
    }, userId: string) => Promise<{
        status: "OK";
        createdNew: boolean;
    } | ErrorResponse>;
    getTenantUsers: (tenantId: string) => Promise<{
        status: "OK";
        users: (User & {
            roles?: string[];
        })[];
    } | ErrorResponse>;
    addInvitation: (email: string, tenantId: string, role: string, metadata: MetadataType) => Promise<{
        status: "OK";
        code: string;
    } | ErrorResponse>;
    removeInvitation: (email: string, tenantId: string, metadata: MetadataType) => Promise<{
        status: "OK";
    } | ErrorResponse>;
    acceptInvitation: (code: string, tenantId: string, session: SessionContainerInterface, metadata: MetadataType) => Promise<{
        status: "OK";
    } | ErrorResponse>;
    getInvitations: (tenantId: string, metadata: MetadataType) => Promise<{
        status: "OK";
        invitees: InviteeDetails[];
    } | ErrorResponse>;
    associateAllLoginMethodsOfUserWithTenant: AssociateAllLoginMethodsOfUserWithTenant;
    addTenantCreationRequest: (session: SessionContainerInterface, tenantDetails: {
        name: string;
        firstFactors?: string[] | null;
    }, metadata: TenantCreationRequestMetadataType, appUrl: string, userContext: UserContext, sendEmail: SendPluginEmail) => Promise<{
        status: "OK";
    } | ErrorResponse>;
    getTenantCreationRequests: (metadata: TenantCreationRequestMetadataType, userContext: UserContext) => Promise<({
        status: "OK";
    } & {
        requests: TenantCreationRequestWithUser[];
    }) | ErrorResponse>;
    acceptTenantCreationRequest: (requestId: string, session: SessionContainerInterface, metadata: TenantCreationRequestMetadataType) => Promise<{
        status: "OK";
    } | ErrorResponse>;
    rejectTenantCreationRequest: (requestId: string, session: SessionContainerInterface, metadata: TenantCreationRequestMetadataType) => Promise<{
        status: "OK";
    } | ErrorResponse>;
    sendTenantCreationRequestEmail: (tenantId: string, creatorEmail: string, appUrl: string, userContext: UserContext, sendEmail: SendPluginEmail) => Promise<void>;
    getAppUrl: GetAppUrl;
    rejectRequestToJoinTenant: (tenantId: string, userId: string) => Promise<{
        status: "OK";
    } | ErrorResponse>;
    doesUserHaveTenantCreationRequest: (userId: string, metadata: TenantCreationRequestMetadataType) => Promise<boolean>;
    getPreferredTenantId: (tenantIds: string[], inputTenantId: string) => string | undefined;
    assignRoleToUserInTenant: (tenantId: string, userId: string, role: string) => Promise<void>;
    shouldHaveTenantAccess: (userId: string, tenantId: string, userContext: UserContext) => Promise<{
        canAccess: boolean;
        reason?: string;
    }>;
};
```

### `TenantCreationRequestMetadataType`

```ts check=false reason="Generated API signature"
import { pluginUserMetadata } from '@shared/nodejs';
type TenantCreationRequestMetadataType = ReturnType<typeof pluginUserMetadata<TenantCreationRequestMetadata>>;
```
