B2B Saas Authentication

/

Frontend SDKs

/

Headless

/

Multi-Factor Authentication

/

Recovery Codes

/

Rotate Recovery Codes

Rotate Recovery Codes

The Rotate Recovery Codes method wraps the Rotate Recovery Codes 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 fields


request_idstring

status_codeint

memberobject

member_idstring

organizationobject

recovery_codesarray[strings]
import React, { useCallback } from 'react';
import { useStytchB2BClient } from '@stytch/react/b2b';

export const Rotate = () => {
  const stytch = useStytchB2BClient();

  const trigger = useCallback(() => {
    stytch.recoveryCodes.rotate();
  }, [stytch]);

  return <button onClick={trigger}>Rotate recovery codes</button>;
};

RESPONSE

200
{
	"member": {...},
	"member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
	"organization": {...},
	"recovery_codes": "[
      "ckss-2skx-ebow",
      "spbc-424h-usy0",
      "hi08-n5tk-lns5",
      "1n6i-l5na-8axe",
      "aduj-eufq-w6yy",
      "i4l3-dxyt-urmx",
      "ayyi-utb0-gj0s",
      "lz0m-02bi-psbx",
      "l2qm-zrk1-8ujs",
      "c2qd-k7m4-ifmc"
    ]",
	"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
	"status_code": 200
}