---
url: "https://vueda.dev/v3/reference/api/js/stores/storeUser/methods/setupTOTPDevice.md"
title: "setupTOTPDevice"
---

# setupTOTPDevice

## Overview

Starts setting up a two-factor device for the signed-in user.
For `email` and `sms`, the server sends a code to the destination; for `totp`, it returns the secret and a QR code.
Before rejecting with an `UnauthorizedError`, refetches the current user, so `authPendingFlow` names the flow
that the server now requires.

## Signature

`setupTOTPDevice(payload)`

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| <span id="param-payload">payload</span> | `object` | yes | The request body. |

#### payload Properties

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="param-payload-destination">destination</span> | `string` |  |  | The email address or phone number; required for `email` and `sms`. |
| <span id="param-payload-method">method</span> | `string` |  |  | The device method: `totp`, `email`, or `sms`. |

### Returns

`Promise`

For `totp`, an object whose `meta` holds `totp_secret` and `totp_svg_data_uri`.

## Source

`client/lib/stores/storeUser.js:510`
