> ## 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.

# Update User

> Update User using the Stytch Next.js SDK

Wraps the [update user](/api-reference/consumer/api/users/update-user) endpoint. Use this method to change the user's `name`, `untrusted metadata`, and `attributes`.

<Info>
  If a user has enrolled another MFA method, this method will require MFA. See the [Multi-factor authentication](../../resources/multi-factor-authentication) section for more details.
</Info>

## Parameters

<ParamField body="name" type="object">
  The name of the user. Each field in the name object is optional.

  <Expandable title="properties">
    <ParamField body="first_name" type="string">
      The first name of the user.
    </ParamField>

    <ParamField body="middle_name" type="string">
      The middle name(s) of the user.
    </ParamField>

    <ParamField body="last_name" type="string">
      The last name of the user.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="untrusted_metadata" type="object">
  The untrusted\_metadata field contains an arbitrary JSON object of application-specific data. Untrusted metadata can be edited by end users directly via the SDK, and **cannot be used to store critical information.** See the [Metadata](/api-reference/consumer/api/resources/metadata) reference for complete field behavior details.
</ParamField>

## Response

<ResponseField name="emails" type="array[objects]">
  An array of email objects for the User.

  <Expandable title="properties">
    <ResponseField name="email_id" type="string">
      The unique ID of a specific email address.
    </ResponseField>

    <ResponseField name="email" type="string">
      The email address.
    </ResponseField>

    <ResponseField name="verified" type="boolean">
      If this method has been successfully authenticated by the User.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="phone_numbers" type="array[objects]">
  An array of phone number objects linked to the User.

  <Expandable title="properties">
    <ResponseField name="phone_id" type="string">
      The unique ID for the phone number.
    </ResponseField>

    <ResponseField name="phone_number" type="string">
      The phone number.
    </ResponseField>

    <ResponseField name="verified" type="boolean">
      If this method has been successfully authenticated by the User.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="crypto_wallets" type="array[objects]">
  An array contains a list of all crypto wallets for a given User in the Stytch API.

  <Expandable title="properties">
    <ResponseField name="crypto_wallet_id" type="string">
      The unique ID for a crypto wallet
    </ResponseField>

    <ResponseField name="crypto_wallet_address" type="string">
      The actual blockchain address of the User's crypto wallet.
    </ResponseField>

    <ResponseField name="crypto_wallet_type" type="string">
      The blockchain that the User's crypto wallet operates on, e.g. Ethereum, Solana, etc.
    </ResponseField>

    <ResponseField name="verified" type="boolean">
      If this method has been successfully authenticated by the User.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="user_id" type="string">
  The unique ID of the affected User.
</ResponseField>

<ResponseField name="user" type="object">
  The user object affected by call.  See the [User object](/api-reference/consumer/api/users/user-object) for complete response field details.

  <Expandable title="properties">
    <ResponseField name="created_at" type="string">
      The timestamp of the User's creation. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.
    </ResponseField>

    <ResponseField name="crypto_wallets" type="array[objects]">
      An array contains a list of all crypto wallets for a given User in the Stytch API.

      <Expandable title="properties">
        <ResponseField name="crypto_wallet_id" type="string">
          The unique ID for a crypto wallet
        </ResponseField>

        <ResponseField name="crypto_wallet_address" type="string">
          The actual blockchain address of the User's crypto wallet.
        </ResponseField>

        <ResponseField name="crypto_wallet_type" type="string">
          The blockchain that the User's crypto wallet operates on, e.g. Ethereum, Solana, etc.
        </ResponseField>

        <ResponseField name="verified" type="boolean">
          If this method has been successfully authenticated by the User.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="emails" type="array[objects]">
      An array of email objects for the User.

      <Expandable title="properties">
        <ResponseField name="email_id" type="string">
          The unique ID of a specific email address.
        </ResponseField>

        <ResponseField name="email" type="string">
          The email address.
        </ResponseField>

        <ResponseField name="verified" type="boolean">
          If this method has been successfully authenticated by the User.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="name" type="object">
      The name of the User. Each field in the name object is optional.

      <Expandable title="properties">
        <ResponseField name="first_name" type="string">
          The first name of the user.
        </ResponseField>

        <ResponseField name="middle_name" type="string">
          The middle name(s) of the user.
        </ResponseField>

        <ResponseField name="last_name" type="string">
          The last name of the user.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="trusted_metadata" type="object">
      The trusted\_metadata field contains an arbitrary JSON object of application-specific data. See the [Metadata](/api-reference/consumer/api/resources/metadata) reference for complete field behavior details.
    </ResponseField>

    <ResponseField name="untrusted_metadata" type="object">
      The untrusted\_metadata field contains an arbitrary JSON object of application-specific data. Untrusted metadata can be edited by end users directly via the SDK, and **cannot be used to store critical information.** See the [Metadata](/api-reference/consumer/api/resources/metadata) reference for complete field behavior details.
    </ResponseField>

    <ResponseField name="phone_numbers" type="array[objects]">
      An array of phone number objects linked to the User.

      <Expandable title="properties">
        <ResponseField name="phone_id" type="string">
          The unique ID for the phone number.
        </ResponseField>

        <ResponseField name="phone_number" type="string">
          The phone number.
        </ResponseField>

        <ResponseField name="verified" type="boolean">
          If this method has been successfully authenticated by the User.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="providers" type="array[objects]">
      An array of OAuth provider objects linked to the User.

      <Expandable title="properties">
        <ResponseField name="oauth_user_registration_id" type="string">
          The unique ID for an OAuth registration.
        </ResponseField>

        <ResponseField name="provider_subject" type="string">
          The unique identifier for the User within a given OAuth provider. Also commonly called the "sub" or "Subject field" in OAuth protocols.
        </ResponseField>

        <ResponseField name="provider_type" type="string">
          Denotes the OAuth identity provider that the user has authenticated with, e.g. Google, Facebook, GitHub etc.
        </ResponseField>

        <ResponseField name="profile_picture_url" type="string">
          If available, the profile\_picture\_url is a url of the User's profile picture set in OAuth identity the provider that the User has authenticated with, e.g. Facebook profile picture.
        </ResponseField>

        <ResponseField name="locale" type="string">
          If available, the locale is the User's locale set in the OAuth identity provider that the user has authenticated with.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="password" type="object">
      The password object is returned for users with a password.

      <Expandable title="properties">
        <ResponseField name="password_id" type="string">
          The unique ID of a specific password
        </ResponseField>

        <ResponseField name="requires_reset" type="boolean">
          Indicates whether this password requires a password reset
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="status" type="string">
      The status of the User. The possible values are `pending` and `active`.
    </ResponseField>

    <ResponseField name="totps" type="array[objects]">
      An array containing a list of all TOTP instances for a given User in the Stytch API.

      <Expandable title="properties">
        <ResponseField name="totp_id" type="string">
          The unique ID for a TOTP instance.
        </ResponseField>

        <ResponseField name="verified" type="boolean">
          If this method has been successfully authenticated by the User.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="user_id" type="string">
      The unique ID of the affected User.
    </ResponseField>

    <ResponseField name="webauthn_registrations" type="array[objects]">
      An array that contains a list of all Passkey or WebAuthn registrations for a given User in the Stytch API.

      <Expandable title="properties">
        <ResponseField name="webauthn_registration_id" type="string">
          The unique ID for the Passkey or WebAuthn registration.
        </ResponseField>

        <ResponseField name="domain" type="string">
          The domain on which Passkey or WebAuthn registration was started. This will be the domain of your app.
        </ResponseField>

        <ResponseField name="user_agent" type="string">
          The user agent of the User.
        </ResponseField>

        <ResponseField name="authenticator_type" type="string">
          The authenticator\_type string displays the requested authenticator type of the Passkey or WebAuthn device. The two valid types are "platform" and "cross-platform". If no value is present, the Passkey or WebAuthn device was created without an authenticator type preference.
        </ResponseField>

        <ResponseField name="verified" type="boolean">
          If this method has been successfully authenticated by the User.
        </ResponseField>

        <ResponseField name="name" type="string">
          The name of the Passkey or WebAuthn registration.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="biometric_registrations" type="array[objects]">
      An array that contains a list of all biometric registrations for a given User in the Stytch API.

      <Expandable title="properties">
        <ResponseField name="biometric_registration_id" type="string">
          The unique ID for a biometric registration.
        </ResponseField>

        <ResponseField name="verified" type="boolean">
          If this method has been successfully authenticated by the User.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="roles" type="array[strings]">
      Roles assigned to this User. See the [RBAC guide](/consumer-auth/authorization/assigning-roles-to-users) for more information about role assignment.
    </ResponseField>
  </Expandable>
</ResponseField>

<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 { useCallback } from 'react';
      import { useStytch } from '@stytch/nextjs';

      export const Login = () => {
        const stytch = useStytch();

        const updateName = useCallback(() => {
          stytch.user.update({
            name: {
              first_name: 'Jane',
              last_name: 'Doe',
            },
            untrusted_metadata: {
              display_theme: 'DARK_MODE',
            },
          });
        }, [stytch]);

        return (
          <>
            <button onClick={updateName}>Update name</button>
          </>
        );
      };
    ```
  </RequestExample>

  <ResponseExample>
    ```json 200 theme={null}
    {
      "emails": [
        {
          "email_id": "email-test-81bf03a8-86e1-4d95-bd44-bb3495224953",
          "email": "sandbox@stytch.com",
          "verified": false
        }
      ],
      "phone_numbers": [
        {
          "phone_id": "phone-number-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
          "phone_number": "+12025550162",
          "verified": false
        }
      ],
      "crypto_wallets": [
        {
          "crypto_wallet_id": "crypto-wallet-test-dbbd372e-79f8-48ea-907c-5f0755e7d328",
          "crypto_wallet_address": "0x6df2dB4Fb3DA35d241901Bd53367770BF03123f1",
          "crypto_wallet_type": "ethereum",
          "verified": true
        }
      ],
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "status_code": 200,
      "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
      "user": {...}
    }
    ```

    ```json 400 theme={null}
    {
        {
          "status_code": 400,
          "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
          "error_type": "update_user_auth_method_not_allowed",
          "error_message": "Update user no longer accepts phone_numbers, emails, or crypto_wallets. To add these authentication factors to an existing user, use their respective Send endpoints.",
          "error_url": "https://stytch.com/docs/api/errors/400"
        }
    }
    ```

    ```json 401 theme={null}
    {
      "status_code": 401,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "unauthorized_credentials",
      "error_message": "Unauthorized credentials.",
      "error_url": "https://stytch.com/docs/api/errors/401"
    }
    ```

    ```json 404 theme={null}
    {
      "status_code": 404,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "user_not_found",
      "error_message": "User could not be found.",
      "error_url": "https://stytch.com/docs/api/errors/404"
    }
    ```

    ```json 429 theme={null}
    {
      "status_code": 429,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "too_many_requests",
      "error_message": "Too many requests have been made.",
      "error_url": "https://stytch.com/docs/api/errors/429"
    }
    ```

    ```json 500 theme={null}
    {
      "status_code": 500,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "internal_server_error",
      "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
      "error_url": "https://stytch.com/docs/api/errors/500"
    }
    ```
  </ResponseExample>
</Panel>
