---
title: supertokens-node/recipe/accountlinking
description: References documentation for the supertokens-node/recipe/accountlinking package
sidebar:
  order: 150
---

## Classes

### default

Defined in: [recipe/accountlinking/index.ts:23](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/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/accountlinking/index.ts:24](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L24) |

#### Methods

##### canCreatePrimaryUser()

```ts check=false reason="Generated API signature"
static canCreatePrimaryUser(recipeUserId, userContext?): Promise<
  | {
  status: "OK";
  wasAlreadyAPrimaryUser: boolean;
}
  | {
  description: string;
  primaryUserId: string;
  status:   | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
     | "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR";
}>;
```

Defined in: [recipe/accountlinking/index.ts:84](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L84)

###### Parameters

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

###### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `wasAlreadyAPrimaryUser`: `boolean`;
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`:   \| `"ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`
     \| `"RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR"`;
\}\>

##### canLinkAccounts()

```ts check=false reason="Generated API signature"
static canLinkAccounts(
   recipeUserId, 
   primaryUserId, 
   userContext?): Promise<
  | {
  accountsAlreadyLinked: boolean;
  status: "OK";
}
  | {
  description: string;
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  status: "INPUT_USER_IS_NOT_A_PRIMARY_USER";
}>;
```

Defined in: [recipe/accountlinking/index.ts:98](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L98)

###### Parameters

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

###### Returns

`Promise`\<
  \| \{
  `accountsAlreadyLinked`: `boolean`;
  `status`: `"OK"`;
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`: `"RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`: `"ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
\}
  \| \{
  `status`: `"INPUT_USER_IS_NOT_A_PRIMARY_USER"`;
\}\>

##### createPrimaryUser()

```ts check=false reason="Generated API signature"
static createPrimaryUser(recipeUserId, userContext?): Promise<
  | {
  status: "OK";
  user: User;
  wasAlreadyAPrimaryUser: boolean;
}
  | {
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR";
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}>;
```

Defined in: [recipe/accountlinking/index.ts:91](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L91)

###### Parameters

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

###### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `user`: [`User`](types#user);
  `wasAlreadyAPrimaryUser`: `boolean`;
\}
  \| \{
  `primaryUserId`: `string`;
  `status`: `"RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR"`;
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`: `"ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
\}\>

##### createPrimaryUserIdOrLinkAccounts()

```ts check=false reason="Generated API signature"
static createPrimaryUserIdOrLinkAccounts(
   tenantId, 
   recipeUserId, 
   session?, 
userContext?): Promise<User>;
```

Defined in: [recipe/accountlinking/index.ts:35](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L35)

This is a function which is a combination of createPrimaryUser and
linkAccounts where the input recipeUserId is either linked to a user that it can be
linked to, or is made into a primary user.

The output will be the user ID of the user that it was linked to, or it will be the
same as the input recipeUserId if it was made into a primary user, or if there was
no linking that happened.

###### Parameters

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

###### Returns

`Promise`\<[`User`](types#user)\>

##### getPrimaryUserThatCanBeLinkedToRecipeUserId()

```ts check=false reason="Generated API signature"
static getPrimaryUserThatCanBeLinkedToRecipeUserId(
   tenantId, 
   recipeUserId, 
userContext?): Promise<User>;
```

Defined in: [recipe/accountlinking/index.ts:67](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L67)

This function returns the primary user that the input recipe ID can be
linked to. It can be used to determine which primary account the linking
will happen to if the input recipe user ID was to be linked.

If the function returns undefined, it means that there is no primary user
that the input recipe ID can be linked to, and therefore it can be made
into a primary user itself.

###### Parameters

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

###### Returns

`Promise`\<[`User`](types#user)\>

##### isEmailChangeAllowed()

```ts check=false reason="Generated API signature"
static isEmailChangeAllowed(
   recipeUserId, 
   newEmail, 
   isVerified, 
   session?, 
userContext?): Promise<boolean>;
```

Defined in: [recipe/accountlinking/index.ts:159](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L159)

###### Parameters

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

###### Returns

`Promise`\<`boolean`\>

##### isSignInAllowed()

```ts check=false reason="Generated API signature"
static isSignInAllowed(
   tenantId, 
   recipeUserId, 
   session?, 
userContext?): Promise<boolean>;
```

Defined in: [recipe/accountlinking/index.ts:137](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L137)

###### Parameters

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

###### Returns

`Promise`\<`boolean`\>

##### isSignUpAllowed()

```ts check=false reason="Generated API signature"
static isSignUpAllowed(
   tenantId, 
   newUser, 
   isVerified, 
   session?, 
userContext?): Promise<boolean>;
```

Defined in: [recipe/accountlinking/index.ts:121](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L121)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `newUser` | [`AccountInfoWithRecipeId`](recipe-accountlinking-types#accountinfowithrecipeid) |
| `isVerified` | `boolean` |
| `session?` | `SessionContainerInterface` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<`boolean`\>

##### linkAccounts()

```ts check=false reason="Generated API signature"
static linkAccounts(
   recipeUserId, 
   primaryUserId, 
   userContext?): Promise<
  | {
  accountsAlreadyLinked: boolean;
  status: "OK";
  user: User;
}
  | {
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
  user: User;
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  status: "INPUT_USER_IS_NOT_A_PRIMARY_USER";
}>;
```

Defined in: [recipe/accountlinking/index.ts:106](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L106)

###### Parameters

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

###### Returns

`Promise`\<
  \| \{
  `accountsAlreadyLinked`: `boolean`;
  `status`: `"OK"`;
  `user`: [`User`](types#user);
\}
  \| \{
  `primaryUserId`: `string`;
  `status`: `"RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
  `user`: [`User`](types#user);
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`: `"ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
\}
  \| \{
  `status`: `"INPUT_USER_IS_NOT_A_PRIMARY_USER"`;
\}\>

##### unlinkAccount()

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

Defined in: [recipe/accountlinking/index.ts:114](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L114)

###### Parameters

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

###### Returns

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

## Variables

### canCreatePrimaryUser()

```ts check=false reason="Generated API signature"
const canCreatePrimaryUser: (recipeUserId, userContext?) => Promise<
  | {
  status: "OK";
  wasAlreadyAPrimaryUser: boolean;
}
  | {
  description: string;
  primaryUserId: string;
  status:   | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
     | "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR";
}> = Wrapper.canCreatePrimaryUser;
```

Defined in: [recipe/accountlinking/index.ts:184](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L184)

#### Parameters

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

#### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `wasAlreadyAPrimaryUser`: `boolean`;
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`:   \| `"ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`
     \| `"RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR"`;
\}\>

***

### canLinkAccounts()

```ts check=false reason="Generated API signature"
const canLinkAccounts: (recipeUserId, primaryUserId, userContext?) => Promise<
  | {
  accountsAlreadyLinked: boolean;
  status: "OK";
}
  | {
  description: string;
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  status: "INPUT_USER_IS_NOT_A_PRIMARY_USER";
}> = Wrapper.canLinkAccounts;
```

Defined in: [recipe/accountlinking/index.ts:186](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L186)

#### Parameters

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

#### Returns

`Promise`\<
  \| \{
  `accountsAlreadyLinked`: `boolean`;
  `status`: `"OK"`;
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`: `"RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`: `"ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
\}
  \| \{
  `status`: `"INPUT_USER_IS_NOT_A_PRIMARY_USER"`;
\}\>

***

### createPrimaryUser()

```ts check=false reason="Generated API signature"
const createPrimaryUser: (recipeUserId, userContext?) => Promise<
  | {
  status: "OK";
  user: User;
  wasAlreadyAPrimaryUser: boolean;
}
  | {
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR";
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}> = Wrapper.createPrimaryUser;
```

Defined in: [recipe/accountlinking/index.ts:185](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L185)

#### Parameters

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

#### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `user`: [`User`](types#user);
  `wasAlreadyAPrimaryUser`: `boolean`;
\}
  \| \{
  `primaryUserId`: `string`;
  `status`: `"RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR"`;
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`: `"ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
\}\>

***

### createPrimaryUserIdOrLinkAccounts()

```ts check=false reason="Generated API signature"
const createPrimaryUserIdOrLinkAccounts: (tenantId, recipeUserId, session?, userContext?) => Promise<User> = Wrapper.createPrimaryUserIdOrLinkAccounts;
```

Defined in: [recipe/accountlinking/index.ts:189](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L189)

This is a function which is a combination of createPrimaryUser and
linkAccounts where the input recipeUserId is either linked to a user that it can be
linked to, or is made into a primary user.

The output will be the user ID of the user that it was linked to, or it will be the
same as the input recipeUserId if it was made into a primary user, or if there was
no linking that happened.

#### Parameters

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

#### Returns

`Promise`\<[`User`](types#user)\>

***

### getPrimaryUserThatCanBeLinkedToRecipeUserId()

```ts check=false reason="Generated API signature"
const getPrimaryUserThatCanBeLinkedToRecipeUserId: (tenantId, recipeUserId, userContext?) => Promise<User> = Wrapper.getPrimaryUserThatCanBeLinkedToRecipeUserId;
```

Defined in: [recipe/accountlinking/index.ts:190](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L190)

This function returns the primary user that the input recipe ID can be
linked to. It can be used to determine which primary account the linking
will happen to if the input recipe user ID was to be linked.

If the function returns undefined, it means that there is no primary user
that the input recipe ID can be linked to, and therefore it can be made
into a primary user itself.

#### Parameters

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

#### Returns

`Promise`\<[`User`](types#user)\>

***

### init()

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

Defined in: [recipe/accountlinking/index.ts:183](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L183)

#### Parameters

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

#### Returns

[`RecipeListFunction`](types#recipelistfunction)

***

### isEmailChangeAllowed()

```ts check=false reason="Generated API signature"
const isEmailChangeAllowed: (recipeUserId, newEmail, isVerified, session?, userContext?) => Promise<boolean> = Wrapper.isEmailChangeAllowed;
```

Defined in: [recipe/accountlinking/index.ts:193](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L193)

#### Parameters

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

#### Returns

`Promise`\<`boolean`\>

***

### isSignInAllowed()

```ts check=false reason="Generated API signature"
const isSignInAllowed: (tenantId, recipeUserId, session?, userContext?) => Promise<boolean> = Wrapper.isSignInAllowed;
```

Defined in: [recipe/accountlinking/index.ts:192](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L192)

#### Parameters

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

#### Returns

`Promise`\<`boolean`\>

***

### isSignUpAllowed()

```ts check=false reason="Generated API signature"
const isSignUpAllowed: (tenantId, newUser, isVerified, session?, userContext?) => Promise<boolean> = Wrapper.isSignUpAllowed;
```

Defined in: [recipe/accountlinking/index.ts:191](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L191)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `newUser` | [`AccountInfoWithRecipeId`](recipe-accountlinking-types#accountinfowithrecipeid) |
| `isVerified` | `boolean` |
| `session?` | `SessionContainerInterface` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<`boolean`\>

***

### linkAccounts()

```ts check=false reason="Generated API signature"
const linkAccounts: (recipeUserId, primaryUserId, userContext?) => Promise<
  | {
  accountsAlreadyLinked: boolean;
  status: "OK";
  user: User;
}
  | {
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
  user: User;
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  status: "INPUT_USER_IS_NOT_A_PRIMARY_USER";
}> = Wrapper.linkAccounts;
```

Defined in: [recipe/accountlinking/index.ts:187](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L187)

#### Parameters

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

#### Returns

`Promise`\<
  \| \{
  `accountsAlreadyLinked`: `boolean`;
  `status`: `"OK"`;
  `user`: [`User`](types#user);
\}
  \| \{
  `primaryUserId`: `string`;
  `status`: `"RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
  `user`: [`User`](types#user);
\}
  \| \{
  `description`: `string`;
  `primaryUserId`: `string`;
  `status`: `"ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"`;
\}
  \| \{
  `status`: `"INPUT_USER_IS_NOT_A_PRIMARY_USER"`;
\}\>

***

### unlinkAccount()

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

Defined in: [recipe/accountlinking/index.ts:188](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/accountlinking/index.ts#L188)

#### Parameters

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

#### Returns

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

## References

### RecipeInterface

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