# Finish signing in with your authenticator code

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

The second step for an account with two-step sign-in: the challenge from POST /auth/verify and the code the authenticator app shows now, or a recovery code.

`POST /auth/two-factor`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Finish signing in with your authenticator code. |
| What does it take? | A JSON body of type [`TwoFactorSignInBody`](https://docs.plotwork.dev/api/schemas.md#twofactorsigninbody). |
| What does it return? | Status 200 with a body of type [`SignInResponse`](https://docs.plotwork.dev/api/schemas.md#signinresponse). |
| What can go wrong? | `400` the body is not valid; `401` the code is wrong (`auth.two_factor_invalid`), or the step expired (`auth.two_factor_expired`); `403` the request came from an origin that may not sign in, or the account is suspended; `429` too many requests. Every failure uses the one error envelope. |

## What it does

The second step for an account with two-step sign-in: the challenge from POST /auth/verify and the code the authenticator app shows now, or a recovery code. A right code opens the session. A wrong one counts against the step, which ends after five or ten minutes.

## Request body

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

| Field | Type | Required | Description |
|---|---|---|---|
| `challenge` | `string` | yes | pattern `^[0-9a-f]{64}$`. |
| `code` | `string` | no | The six digits the authenticator app shows now. pattern `^\d{6}$`. |
| `recoveryCode` | `string` | no | One of the recovery codes made when two-step sign-in was turned on. Each works once. at least 10 characters; at most 32 characters. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | Signed in. | [`SignInResponse`](https://docs.plotwork.dev/api/schemas.md#signinresponse) |
| 400 | The body is not valid. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 401 | The code is wrong (`auth.two_factor_invalid`), or the step expired (`auth.two_factor_expired`). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 403 | The request came from an origin that may not sign in, or the account is suspended. | [`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 [`SignInResponse`](https://docs.plotwork.dev/api/schemas.md#signinresponse).

| Field | Type | Required | Description |
|---|---|---|---|
| `user` | `Account` | yes |  |
| `user.id` | `string` | yes |  |
| `user.email` | `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 |
