---
title: supertokens-web-js/recipe/totp
description: References documentation for the supertokens-web-js/recipe/totp package
sidebar:
  order: 190
---

## Classes

### default

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:28](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L28)

#### Constructors

##### Constructor

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

###### Returns

[`default`](#default)

#### Methods

##### createDevice()

```ts check=false reason="Generated API signature"
static createDevice(input?): Promise<
  | {
  deviceName: string;
  fetchResponse: Response;
  qrCodeString: string;
  secret: string;
  status: "OK";
}
  | {
  fetchResponse: Response;
  status: "DEVICE_ALREADY_EXISTS_ERROR";
}>;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:44](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L44)

Creates a new unverified device.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `input?` | \{ `deviceName?`: `string`; `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `userContext?`: `any`; \} |
| `input.deviceName?` | `string` |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.userContext?` | `any` |

###### Returns

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

`{ status: "OK", ...}` if successful along a description of the created device (secret, etc.)

##### init()

```ts check=false reason="Generated API signature"
static init(config?): CreateRecipeFunction<PreAndPostAPIHookAction>;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:29](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L29)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `config?` | [`UserInput`](recipe-totp-types#userinput) |

###### Returns

[`CreateRecipeFunction`](types#createrecipefunction)\<[`PreAndPostAPIHookAction`](recipe-totp-types#preandpostapihookaction)\>

##### listDevices()

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

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:153](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L153)

Lists all TOTP devices of the current user

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `input?` | \{ `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `userContext?`: `any`; \} |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.userContext?` | `any` |

###### Returns

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

`{ status: "OK", ...}` if successful with a list of devices in the `devices` prop

##### removeDevice()

```ts check=false reason="Generated API signature"
static removeDevice(input): Promise<{
  didDeviceExist: boolean;
  fetchResponse: Response;
  status: "OK";
}>;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:133](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L133)

Removes a TOTP device

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | \{ `deviceName`: `string`; `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `userContext?`: `any`; \} |
| `input.deviceName` | `string` |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.userContext?` | `any` |

###### Returns

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

`{ status: "OK", ...}` if successful

##### verifyCode()

```ts check=false reason="Generated API signature"
static verifyCode(input): Promise<
  | {
  fetchResponse: Response;
  status: "OK";
}
  | {
  currentNumberOfFailedAttempts: number;
  fetchResponse: Response;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  fetchResponse: Response;
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}>;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:71](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L71)

Verifies that the totp code belongs to a verified device of the current user

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | \{ `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `totp`: `string`; `userContext?`: `any`; \} |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.totp` | `string` |
| `input.userContext?` | `any` |

###### Returns

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

`{ status: "OK", ...}` if successful

##### verifyDevice()

```ts check=false reason="Generated API signature"
static verifyDevice(input): Promise<
  | {
  fetchResponse: Response;
  status: "OK";
  wasAlreadyVerified: boolean;
}
  | {
  currentNumberOfFailedAttempts: number;
  fetchResponse: Response;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  fetchResponse: Response;
  status: "UNKNOWN_DEVICE_ERROR";
}
  | {
  fetchResponse: Response;
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}>;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:100](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L100)

Verifies the totp device for the current user

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | \{ `deviceName`: `string`; `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `totp`: `string`; `userContext?`: `any`; \} |
| `input.deviceName` | `string` |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.totp` | `string` |
| `input.userContext?` | `any` |

###### Returns

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

`{ status: "OK", ...}` if successful

## Variables

### createDevice()

```ts check=false reason="Generated API signature"
const createDevice: (input?) => Promise<
  | {
  deviceName: string;
  fetchResponse: Response;
  qrCodeString: string;
  secret: string;
  status: "OK";
}
  | {
  fetchResponse: Response;
  status: "DEVICE_ALREADY_EXISTS_ERROR";
}> = RecipeWrapper.createDevice;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:166](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L166)

Creates a new unverified device.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input?` | \{ `deviceName?`: `string`; `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `userContext?`: `any`; \} |
| `input.deviceName?` | `string` |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.userContext?` | `any` |

#### Returns

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

`{ status: "OK", ...}` if successful along a description of the created device (secret, etc.)

***

### init()

```ts check=false reason="Generated API signature"
const init: (config?) => CreateRecipeFunction<PreAndPostAPIHookAction> = RecipeWrapper.init;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:165](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L165)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `config?` | [`UserInput`](recipe-totp-types#userinput) |

#### Returns

[`CreateRecipeFunction`](types#createrecipefunction)\<[`PreAndPostAPIHookAction`](recipe-totp-types#preandpostapihookaction)\>

***

### listDevices()

```ts check=false reason="Generated API signature"
const listDevices: (input?) => Promise<{
  devices: object[];
  fetchResponse: Response;
  status: "OK";
}> = RecipeWrapper.listDevices;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:170](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L170)

Lists all TOTP devices of the current user

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input?` | \{ `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `userContext?`: `any`; \} |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.userContext?` | `any` |

#### Returns

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

`{ status: "OK", ...}` if successful with a list of devices in the `devices` prop

***

### removeDevice()

```ts check=false reason="Generated API signature"
const removeDevice: (input) => Promise<{
  didDeviceExist: boolean;
  fetchResponse: Response;
  status: "OK";
}> = RecipeWrapper.removeDevice;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:169](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L169)

Removes a TOTP device

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | \{ `deviceName`: `string`; `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `userContext?`: `any`; \} |
| `input.deviceName` | `string` |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.userContext?` | `any` |

#### Returns

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

`{ status: "OK", ...}` if successful

***

### verifyCode()

```ts check=false reason="Generated API signature"
const verifyCode: (input) => Promise<
  | {
  fetchResponse: Response;
  status: "OK";
}
  | {
  currentNumberOfFailedAttempts: number;
  fetchResponse: Response;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  fetchResponse: Response;
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}> = RecipeWrapper.verifyCode;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:167](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L167)

Verifies that the totp code belongs to a verified device of the current user

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | \{ `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `totp`: `string`; `userContext?`: `any`; \} |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.totp` | `string` |
| `input.userContext?` | `any` |

#### Returns

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

`{ status: "OK", ...}` if successful

***

### verifyDevice()

```ts check=false reason="Generated API signature"
const verifyDevice: (input) => Promise<
  | {
  fetchResponse: Response;
  status: "OK";
  wasAlreadyVerified: boolean;
}
  | {
  currentNumberOfFailedAttempts: number;
  fetchResponse: Response;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  fetchResponse: Response;
  status: "UNKNOWN_DEVICE_ERROR";
}
  | {
  fetchResponse: Response;
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}> = RecipeWrapper.verifyDevice;
```

Defined in: [tmp/supertokens-web-js/lib/ts/recipe/totp/index.ts:168](https://github.com/supertokens/supertokens-web-js/blob/be2e0fd7dcade8352cdc9639abe968e5cda5b1cd/lib/ts/recipe/totp/index.ts#L168)

Verifies the totp device for the current user

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | \{ `deviceName`: `string`; `options?`: [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions); `totp`: `string`; `userContext?`: `any`; \} |
| `input.deviceName` | `string` |
| `input.options?` | [`RecipeFunctionOptions`](recipe-emailpassword#recipefunctionoptions) |
| `input.totp` | `string` |
| `input.userContext?` | `any` |

#### Returns

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

`{ status: "OK", ...}` if successful

## References

### DeviceInfo

Re-exports [DeviceInfo](recipe-totp-types#deviceinfo)

***

### PostAPIHookContext

Re-exports [PostAPIHookContext](recipe-totp-types#postapihookcontext)

***

### PreAndPostAPIHookAction

Re-exports [PreAndPostAPIHookAction](recipe-totp-types#preandpostapihookaction)

***

### PreAPIHookContext

Re-exports [PreAPIHookContext](recipe-totp-types#preapihookcontext)

***

### RecipeFunctionOptions

Re-exports [RecipeFunctionOptions](recipe-emailpassword#recipefunctionoptions)

***

### RecipeInterface

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

***

### UserInput

Re-exports [UserInput](recipe-totp-types#userinput)
