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

# Rotate Recovery Codes

> Rotate backup recovery codes using the Stytch React SDK

`recoveryCodes.rotate` wraps the [Rotate Recovery Codes](/docs/api-reference/b2b/api/mfa/recovery-codes/recover) API endpoint.

Rotation requires a logged-in Member Session, as both `organization_id` and `member_id` will be inferred from the session. All existing recovery codes will be invalidated and new ones will be generated.

## Response

<ParamField path="recovery_codes" type="string[]">
  The new set of recovery codes used to authenticate the member without an authenticator app.
</ParamField>

<ResponseField name="request_id" type="string">
  Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we
  may ask for this value to help identify a specific API call when helping you debug an issue.
</ResponseField>

<ResponseField name="status_code" type="number">
  The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values
  equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
</ResponseField>

<Panel>
  <RequestExample>
    ```jsx theme={null}
    import { useState } from 'react';
    import { useStytchB2BClient } from '@stytch/react/b2b';

    export const RotateRecoveryCodes = () => {
      const stytch = useStytchB2BClient();
      const [newCodes, setNewCodes] = useState([]);

      const rotateCodes = async () => {
        const response = await stytch.mfa.recoveryCodes.rotate({
          organization_id: 'organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931',
          member_id: 'member-test-32fc5024-9c09-4da3-bd2e-c9698807585d',
        });
        setNewCodes(response.recovery_codes);
        console.log('New recovery codes:', response.recovery_codes);
      };

      return (
        <div>
          <button onClick={rotateCodes}>Rotate Recovery Codes</button>
          {newCodes.length > 0 && (
            <div>
              <h3>New Recovery Codes</h3>
              {newCodes.map((code, index) => (
                <p key={index}>{code}</p>
              ))}
            </div>
          )}
        </div>
      );
    };
    ```
  </RequestExample>
</Panel>
