# Make new recovery codes

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

Makes ten new one-time recovery codes, proved with the current code, and answers them once.

`POST /user/two-factor/recovery-codes`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Make new recovery codes. |
| What does it take? | A JSON body of type [`TotpCodeBody`](https://docs.plotwork.dev/api/schemas.md#totpcodebody). |
| What does it return? | Status 200 with a body of type [`RecoveryCodes`](https://docs.plotwork.dev/api/schemas.md#recoverycodes). |
| What can go wrong? | `400` the body is not valid; `401` not signed in, or the code is wrong (`auth.two_factor_invalid`); `403` the request came from an origin that may not make changes; `409` two-step sign-in is not on (`account.two_factor_off`); `429` too many requests. Every failure uses the one error envelope. |

## What it does

Makes ten new one-time recovery codes, proved with the current code, and answers them once. The old ones stop working.

## Request body

The body has the type [`TotpCodeBody`](https://docs.plotwork.dev/api/schemas.md#totpcodebody).

| Field | Type | Required | Description |
|---|---|---|---|
| `code` | `string` | yes | The six digits the authenticator app shows now. pattern `^\d{6}$`. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | The new codes. | [`RecoveryCodes`](https://docs.plotwork.dev/api/schemas.md#recoverycodes) |
| 400 | The body is not valid. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 401 | Not signed in, or the code is wrong (`auth.two_factor_invalid`). | [`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 not on (`account.two_factor_off`). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 429 | Too many requests. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |

## Response body

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

| Field | Type | Required | Description |
|---|---|---|---|
| `recoveryCodes` | `string[]` | yes |  |

## 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 |
