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

# Generate recovery codes

> Ten new codes, shown once, after the password; the earlier ones stop working.



## OpenAPI

````yaml openapi/en/control.json POST /v1/users/me/recovery-codes
openapi: 3.1.0
info:
  title: Niadra control API
  version: '1'
  description: >-
    Tenants, projects, sources, keys, people, configuration and usage. It never
    receives customer content.
servers:
  - url: https://control.api.niadra.com
security: []
paths:
  /v1/users/me/recovery-codes:
    post:
      summary: Generate recovery codes
      description: >-
        Ten new recovery codes for the signed-in person, shown once; the earlier
        ones stop working. Asks for

        the password again, and a wrong one answers 403, so a typo never ends
        the session. 409 while the

        person has no confirmed authenticator.


        **Authentication.** Person token issued by the control plane
        (`Authorization: Bearer <JWT>`), with the role the operation needs.
      operationId: regenerate_recovery_codes_v1_users_me_recovery_codes_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PasswordRequest'
            example:
              password: correct horse battery staple
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecoveryCodesOut'
              example:
                recovery_codes:
                  - 7KQ2M-XA9BD
                  - H3VNP-8R2TW
                  - C4ZE6-JM7QK
                  - P9WXT-2BD5N
                  - R8HCV-6KMZ3
                  - T2NQA-WV47H
                  - Y6DJ9-QX3PC
                  - B5MRK-HT8WZ
                  - E7GXN-4PQ2V
                  - W3ZKC-9NBHD
          description: The new recovery codes, shown once.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: The request does not match the contract.
      security:
        - personToken: []
components:
  schemas:
    PasswordRequest:
      additionalProperties: false
      properties:
        password:
          anyOf:
            - maxLength: 1024
              minLength: 1
              type: string
            - type: 'null'
          description: >-
            The person's password once more: a session alone does not change the
            second factor.
          title: Password
        totp:
          anyOf:
            - pattern: ^\d{6}$
              type: string
            - type: 'null'
          description: >-
            In place of the password, only for a person the tenant's SSO
            created, who has none: the current code of the authenticator app.
          title: Totp
      title: PasswordRequest
      type: object
    RecoveryCodesOut:
      additionalProperties: false
      properties:
        recovery_codes:
          description: >-
            Ten single-use codes, `XXXXX-XXXXX`. Shown once; Niadra keeps only a
            keyed hash of each, and the earlier codes of the person no longer
            work.
          items:
            type: string
          title: Recovery Codes
          type: array
      required:
        - recovery_codes
      title: RecoveryCodesOut
      type: object
    Problem:
      additionalProperties: false
      description: RFC 9457 problem details; `code` comes from the versioned error catalog.
      properties:
        code:
          title: Code
          type: string
        detail:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Detail
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Request Id
        status:
          title: Status
          type: integer
        title:
          title: Title
          type: string
        type:
          default: about:blank
          title: Type
          type: string
      required:
        - title
        - status
        - code
      title: Problem
      type: object
  securitySchemes:
    personToken:
      type: http
      scheme: bearer
      bearerFormat: JWT

````