updateUserById()

Updates the user data.

1const { data: user, error } = await supabase.auth.admin.updateUserById(
2  '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
3  { user_metadata: { hello: 'world' } }
4)

Parameters#

  • uidrequired
    string

    No description provided.

  • AdminUserAttributesrequired
    object

    No description provided.

      Properties
    • app_metadataoptional
      object

      A custom data object to store the user's application specific metadata. This maps to the auth.users.app_metadata column.

      Only a service role can modify.

      The app_metadata should be a JSON object that includes app-specific info, such as identity providers, roles, and other access control information.

    • ban_durationoptional
      string

      Determines how long a user is banned for.

      The format for the ban duration follows a strict sequence of decimal numbers with a unit suffix. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

      For example, some possible durations include: '300ms', '2h45m'.

      Setting the ban duration to 'none' lifts the ban on the user.

    • dataoptional
      object

      A custom data object to store the user's metadata. This maps to the auth.users.user_metadata column.

      The data should be a JSON object that includes user-specific info, such as their first and last name.

    • emailoptional
      string

      The user's email.

    • email_confirmoptional
      boolean

      Confirms the user's email address if set to true.

      Only a service role can modify.

    • passwordoptional
      string

      The user's password.

    • phoneoptional
      string

      The user's phone.

    • phone_confirmoptional
      boolean

      Confirms the user's phone number if set to true.

      Only a service role can modify.

    • user_metadataoptional
      object

      A custom data object to store the user's metadata. This maps to the auth.users.user_metadata column.

      Only a service role can modify.

      The user_metadata should be a JSON object that includes user-specific info, such as their first and last name.

      Note: When using the GoTrueAdminApi and wanting to modify a user's metadata, this attribute is used instead of UserAttributes data.

Examples#

Updates a user's email.#

1const { data: user, error } = await supabase.auth.admin.updateUserById(
2  '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
3  { email: 'new@email.com' }
4)

Updates a user's password.#

1const { data: user, error } = await supabase.auth.admin.updateUserById(
2  '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
3  { password: 'new_password' }
4)

Updates a user's metadata.#

1const { data: user, error } = await supabase.auth.admin.updateUserById(
2  '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
3  { user_metadata: { hello: 'world' } }
4)

Updates a user's app_metadata.#

1const { data: user, error } = await supabase.auth.admin.updateUserById(
2  '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
3  { app_metadata: { plan: 'trial' } }
4)

Confirms a user's email address.#

1const { data: user, error } = await supabase.auth.admin.updateUserById(
2  '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
3  { email_confirm: true }
4)

Confirms a user's phone number.#

1const { data: user, error } = await supabase.auth.admin.updateUserById(
2  '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
3  { phone_confirm: true }
4)