# Start setting up an authenticator app

> Page: https://docs.plotwork.dev/api/post-user-two-factor-setup. Index of every page: https://docs.plotwork.dev/llms.txt

Makes a new secret for an authenticator app and answers it once.

`POST /user/two-factor/setup`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Start setting up an authenticator app. |
| What does it take? | Nothing. |
| What does it return? | Status 200 with a body of type [`TwoFactorSetup`](https://docs.plotwork.dev/api/schemas.md#twofactorsetup). |
| What can go wrong? | `401` not signed in; `403` the request came from an origin that may not make changes; `409` two-step sign-in is already on (`account.two_factor_on`); `429` too many requests; `503` this server cannot set up two-step sign-in (`account.two_factor_unavailable`). Every failure uses the one error envelope. |

## What it does

Makes a new secret for an authenticator app and answers it once. Nothing is turned on until POST /user/two-factor/enable gets a right code from the app.

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | The secret, shown once. | [`TwoFactorSetup`](https://docs.plotwork.dev/api/schemas.md#twofactorsetup) |
| 401 | Not signed in. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 403 | The request came from an origin that may not make changes. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 409 | Two-step sign-in is already on (`account.two_factor_on`). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 429 | Too many requests. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 503 | This server cannot set up two-step sign-in (`account.two_factor_unavailable`). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |

## Response body

A 200 answer has the type [`TwoFactorSetup`](https://docs.plotwork.dev/api/schemas.md#twofactorsetup).

| Field | Type | Required | Description |
|---|---|---|---|
| `secret` | `string` | yes | The shared secret in base32, for typing into an app that cannot scan. |
| `uri` | `string` | yes | The otpauth:// address an authenticator app scans as a QR code. |

## See also

| Doc | Why |
|---|---|
| [API reference](https://docs.plotwork.dev/api/reference.md) | Every endpoint, and the error envelope |
| [Schemas](https://docs.plotwork.dev/api/schemas.md) | Every request and response type |
| [Tool reference](https://docs.plotwork.dev/mcp/tools.md) | The operations as callable tools |
