---
title: "Regenerate recovery codes"
method: POST
path: "/auth/totp/recovery-codes"
---

# Regenerate recovery codes

`POST /auth/totp/recovery-codes`

## Request

- Base URL: `https://app.yoping.me/api/v1`
- URL: `https://app.yoping.me/api/v1/auth/totp/recovery-codes`
- Auth: API key in cookie `yp_session`

Mints a fresh set of 8 recovery codes, replacing (and invalidating) the previous set. TOTP code only — a found recovery code must not be able to mint itself seven new siblings. 400 if 2FA is not enabled or the code is invalid or not a TOTP code. Shares the per-user 5 code attempts per minute limiter with setup, confirm, disable, and login phase 2.

## Request body

- TOTPRecoveryCodesRequest
  - `code` string, required: A 6-digit TOTP code. Recovery codes are not accepted for regeneration.

## Response `200`

New recovery codes generated; raw codes returned once.

- object: Uniform success envelope: the payload is always under `data`.
  - `data` object, required
    - `recovery_codes` string[], required: 8 single-use recovery codes; shown only this once, replacing the previous set.

## Other responses

- `400`: Invalid input (code `validation_failed`): malformed JSON, a missing or out-of-range field, bad pagination parameters, or a rejected token.
- `401`: Not authenticated (code `unauthorized`): missing, invalid, or expired session; invalid login credentials; or a Bearer token, which this surface rejects.
- `403`: Forbidden. Code `forbidden` for a cross-origin (CSRF) request blocked by origin validation or for API-key management attempted without a browser session; `account_suspended` when a suspended account attempts a mutation; `account_deleted` when an account in its deletion grace window calls a non-exempt route.
- `429`: Too many requests (code `rate_limited`). A global per-IP budget of 300 requests/minute (burst 60) applies to every endpoint; login, signup, and test alerts have tighter dedicated limits.

---

[API](https://skmtc.dev/yoping/apis/yopingme-api.md) · [All operations](https://skmtc.dev/yoping/apis/yopingme-api/llms.txt) · [OpenAPI document](https://skmtc.dev/yoping/apis/yopingme-api/revisions/76d8deb40173?raw)
