> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pacifica.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Regenerate Recovery Keys

> This endpoint allows users to replace their recovery keys with a new set.

```http theme={null}
POST /api/v1/account/2fa/recovery-keys/regenerate
```

Replaces your [recovery keys](https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor#recovery-keys) with a new set of 10. Your old keys stop working, including unused ones.

#### Operation Type (for Signing)

| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"regenerate_recovery_keys"` |

#### Request Body

<table><thead><tr><th width="176">Field</th><th width="98">Type</th><th width="95">Need</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td>`"account"`</td><td>string</td><td>required</td><td>User's wallet address</td><td>`42trU9A5...`</td></tr><tr><td>`"signature"`</td><td>string</td><td>required</td><td>Cryptographic signature</td><td>`5j1Vy9Uq...`</td></tr><tr><td>`"timestamp"`</td><td>integer</td><td>required</td><td>Current timestamp in milliseconds</td><td>`1716200000000`</td></tr><tr><td>`"proof"`</td><td>object</td><td>required</td><td>Proof. A recovery key works. Not part of the signed payload. See [Proofs](https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor#proofs)</td><td>`{"type": "totp", "code": "123456"}`</td></tr><tr><td>`"expiry_window"`</td><td>integer</td><td>optional</td><td>Signature expiry in milliseconds</td><td>`30000`</td></tr></tbody></table>

```json theme={null}
{
  "account": "42trU9A5...",
  "signature": "5j1Vy9Uq...",
  "timestamp": 1716200000000,
  "proof": {
    "type": "totp",
    "code": "123456"
  },
  "expiry_window": 30000
}
```

Sign this request with the account's own key. Agent wallets cannot sign it. The account must be a main account.

This call also ends every enrollment in progress.

#### Signing

The `data` object is empty. Do not sign `proof`. For the request above, the message to sign is:

```json theme={null}
{"data":{},"expiry_window":30000,"timestamp":1716200000000,"type":"regenerate_recovery_keys"}
```

#### Response

* Status 200: Recovery keys replaced

```json theme={null}
{
  "success": true,
  "data": {
    "recovery_keys": [
      "3f9a-1c0b-77de-a4e2-0b19-5c6d-e8f0-2a7b",
      "9e2d-4b7a-0c61-f385-a7d2-6e19-3b40-c8f5",
      "..."
    ]
  },
  "error": null,
  "code": null
}
```

| Field | Type | Description |
| - | - | - |
| `'recovery_keys'` | array | The 10 new recovery keys |

Pacifica shows recovery keys only once. Store them somewhere safe.

* Status 400: Invalid request parameters or signature
* Status 401: The proof is wrong, expired, or already used
* Status 403: The account is a subaccount, or it does not exist
* Status 422: 2FA is off (`two-factor is not enabled`)
* Status 429: Too many proof attempts
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later

#### Code Example (Python)

```python theme={null}
import requests

payload = {
    "account": "42trU9A5...",
    "signature": "5j1Vy9Uq...",
    "timestamp": 1716200000000,
    "proof": {"type": "totp", "code": "123456"}
}

response = requests.post(
    "/api/v1/account/2fa/recovery-keys/regenerate",
    json=payload,
    headers={"Content-Type": "application/json"}
)

data = response.json()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.