---
title: supertokens-node/recipe/totp
description: References documentation for the supertokens-node/recipe/totp package
sidebar:
  order: 310
---

## Classes

### default

Defined in: [recipe/totp/index.ts:20](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L20)

#### 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/totp/index.ts:21](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L21) |

#### Methods

##### createDevice()

```ts check=false reason="Generated API signature"
static createDevice(
   userId, 
   userIdentifierInfo?, 
   deviceName?, 
   skew?, 
   period?, 
   userContext?): Promise<
  | {
  deviceName: string;
  qrCodeString: string;
  secret: string;
  status: "OK";
}
  | {
  status: "DEVICE_ALREADY_EXISTS_ERROR";
}
  | {
  status: "UNKNOWN_USER_ID_ERROR";
}>;
```

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

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `userId` | `string` |
| `userIdentifierInfo?` | `string` |
| `deviceName?` | `string` |
| `skew?` | `number` |
| `period?` | `number` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `deviceName`: `string`;
  `qrCodeString`: `string`;
  `secret`: `string`;
  `status`: `"OK"`;
\}
  \| \{
  `status`: `"DEVICE_ALREADY_EXISTS_ERROR"`;
\}
  \| \{
  `status`: `"UNKNOWN_USER_ID_ERROR"`;
\}\>

##### listDevices()

```ts check=false reason="Generated API signature"
static listDevices(userId, userContext?): Promise<{
  devices: object[];
  status: "OK";
}>;
```

Defined in: [recipe/totp/index.ts:70](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L70)

###### Parameters

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

###### Returns

`Promise`\<\{
  `devices`: `object`[];
  `status`: `"OK"`;
\}\>

##### removeDevice()

```ts check=false reason="Generated API signature"
static removeDevice(
   userId, 
   deviceName, 
   userContext?): Promise<{
  didDeviceExist: boolean;
  status: "OK";
}>;
```

Defined in: [recipe/totp/index.ts:88](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L88)

###### Parameters

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

###### Returns

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

##### updateDevice()

```ts check=false reason="Generated API signature"
static updateDevice(
   userId, 
   existingDeviceName, 
   newDeviceName, 
   userContext?): Promise<{
  status: "OK" | "DEVICE_ALREADY_EXISTS_ERROR" | "UNKNOWN_DEVICE_ERROR";
}>;
```

Defined in: [recipe/totp/index.ts:54](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L54)

###### Parameters

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

###### Returns

`Promise`\<\{
  `status`: `"OK"` \| `"DEVICE_ALREADY_EXISTS_ERROR"` \| `"UNKNOWN_DEVICE_ERROR"`;
\}\>

##### verifyDevice()

```ts check=false reason="Generated API signature"
static verifyDevice(
   tenantId, 
   userId, 
   deviceName, 
   totp, 
   userContext?): Promise<
  | {
  status: "OK";
  wasAlreadyVerified: boolean;
}
  | {
  status: "UNKNOWN_DEVICE_ERROR";
}
  | {
  currentNumberOfFailedAttempts: number;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}>;
```

Defined in: [recipe/totp/index.ts:103](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L103)

###### Parameters

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

###### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `wasAlreadyVerified`: `boolean`;
\}
  \| \{
  `status`: `"UNKNOWN_DEVICE_ERROR"`;
\}
  \| \{
  `currentNumberOfFailedAttempts`: `number`;
  `maxNumberOfFailedAttempts`: `number`;
  `status`: `"INVALID_TOTP_ERROR"`;
\}
  \| \{
  `retryAfterMs`: `number`;
  `status`: `"LIMIT_REACHED_ERROR"`;
\}\>

##### verifyTOTP()

```ts check=false reason="Generated API signature"
static verifyTOTP(
   tenantId, 
   userId, 
   totp, 
   userContext?): Promise<
  | {
  status: "OK" | "UNKNOWN_USER_ID_ERROR";
}
  | {
  currentNumberOfFailedAttempts: number;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}>;
```

Defined in: [recipe/totp/index.ts:136](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L136)

###### Parameters

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

###### Returns

`Promise`\<
  \| \{
  `status`: `"OK"` \| `"UNKNOWN_USER_ID_ERROR"`;
\}
  \| \{
  `currentNumberOfFailedAttempts`: `number`;
  `maxNumberOfFailedAttempts`: `number`;
  `status`: `"INVALID_TOTP_ERROR"`;
\}
  \| \{
  `retryAfterMs`: `number`;
  `status`: `"LIMIT_REACHED_ERROR"`;
\}\>

## Variables

### createDevice()

```ts check=false reason="Generated API signature"
createDevice: (userId, userIdentifierInfo?, deviceName?, skew?, period?, userContext?) => Promise<
  | {
  deviceName: string;
  qrCodeString: string;
  secret: string;
  status: "OK";
}
  | {
  status: "DEVICE_ALREADY_EXISTS_ERROR";
}
  | {
  status: "UNKNOWN_USER_ID_ERROR";
}> = Wrapper.createDevice;
```

Defined in: [recipe/totp/index.ts:166](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L166)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `userId` | `string` |
| `userIdentifierInfo?` | `string` |
| `deviceName?` | `string` |
| `skew?` | `number` |
| `period?` | `number` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `deviceName`: `string`;
  `qrCodeString`: `string`;
  `secret`: `string`;
  `status`: `"OK"`;
\}
  \| \{
  `status`: `"DEVICE_ALREADY_EXISTS_ERROR"`;
\}
  \| \{
  `status`: `"UNKNOWN_USER_ID_ERROR"`;
\}\>

***

### init()

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

Defined in: [recipe/totp/index.ts:164](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L164)

#### Parameters

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

#### Returns

[`RecipeListFunction`](types#recipelistfunction)

***

### listDevices()

```ts check=false reason="Generated API signature"
listDevices: (userId, userContext?) => Promise<{
  devices: object[];
  status: "OK";
}> = Wrapper.listDevices;
```

Defined in: [recipe/totp/index.ts:167](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L167)

#### Parameters

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

#### Returns

`Promise`\<\{
  `devices`: `object`[];
  `status`: `"OK"`;
\}\>

***

### removeDevice()

```ts check=false reason="Generated API signature"
removeDevice: (userId, deviceName, userContext?) => Promise<{
  didDeviceExist: boolean;
  status: "OK";
}> = Wrapper.removeDevice;
```

Defined in: [recipe/totp/index.ts:169](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L169)

#### Parameters

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

#### Returns

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

***

### updateDevice()

```ts check=false reason="Generated API signature"
updateDevice: (userId, existingDeviceName, newDeviceName, userContext?) => Promise<{
  status: "OK" | "DEVICE_ALREADY_EXISTS_ERROR" | "UNKNOWN_DEVICE_ERROR";
}> = Wrapper.updateDevice;
```

Defined in: [recipe/totp/index.ts:168](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L168)

#### Parameters

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

#### Returns

`Promise`\<\{
  `status`: `"OK"` \| `"DEVICE_ALREADY_EXISTS_ERROR"` \| `"UNKNOWN_DEVICE_ERROR"`;
\}\>

***

### verifyDevice()

```ts check=false reason="Generated API signature"
verifyDevice: (tenantId, userId, deviceName, totp, userContext?) => Promise<
  | {
  status: "OK";
  wasAlreadyVerified: boolean;
}
  | {
  status: "UNKNOWN_DEVICE_ERROR";
}
  | {
  currentNumberOfFailedAttempts: number;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}> = Wrapper.verifyDevice;
```

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

#### Parameters

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

#### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `wasAlreadyVerified`: `boolean`;
\}
  \| \{
  `status`: `"UNKNOWN_DEVICE_ERROR"`;
\}
  \| \{
  `currentNumberOfFailedAttempts`: `number`;
  `maxNumberOfFailedAttempts`: `number`;
  `status`: `"INVALID_TOTP_ERROR"`;
\}
  \| \{
  `retryAfterMs`: `number`;
  `status`: `"LIMIT_REACHED_ERROR"`;
\}\>

***

### verifyTOTP()

```ts check=false reason="Generated API signature"
verifyTOTP: (tenantId, userId, totp, userContext?) => Promise<
  | {
  status: "OK" | "UNKNOWN_USER_ID_ERROR";
}
  | {
  currentNumberOfFailedAttempts: number;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}> = Wrapper.verifyTOTP;
```

Defined in: [recipe/totp/index.ts:171](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/totp/index.ts#L171)

#### Parameters

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

#### Returns

`Promise`\<
  \| \{
  `status`: `"OK"` \| `"UNKNOWN_USER_ID_ERROR"`;
\}
  \| \{
  `currentNumberOfFailedAttempts`: `number`;
  `maxNumberOfFailedAttempts`: `number`;
  `status`: `"INVALID_TOTP_ERROR"`;
\}
  \| \{
  `retryAfterMs`: `number`;
  `status`: `"LIMIT_REACHED_ERROR"`;
\}\>

## References

### APIInterface

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

***

### APIOptions

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

***

### RecipeInterface

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