Skip to main content
Version: v2 RC

updateUserById()

Updates the user data.

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

Parameters

  • uidrequiredstring

    No description provided.

  • AdminUserAttributesrequiredobject

    No description provided.

      Properties
    • app_metadataoptionalobject

      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.

    • dataoptionalobject

      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.

    • emailoptionalstring

      The user's email.

    • email_confirmoptionalboolean

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

      Only a service role can modify.

    • passwordoptionalstring

      The user's password.

    • phoneoptionalstring

      The user's phone.

    • phone_confirmoptionalboolean

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

      Only a service role can modify.

    • user_metadataoptionalobject

      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.

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

Updates a user's password.

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

Updates a user's metadata.

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

Updates a user's app_metadata.

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

Confirms a user's email address.

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

Confirms a user's phone number.

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