--- id: auth-api-updateuserbyid title: 'updateUserById()' slug: auth-api-updateuserbyid custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v1_legacy.yml --- import Tabs from '@theme/Tabs' import TabItem from '@theme/TabItem' Updates the user data. ```js const { data: user, error } = await supabase.auth.api.updateUserById( '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4', { email: 'new@email.com' } ) ``` ## Parameters ## Notes - Requires a `service_role` key. - This function should only be called on a server. Never expose your `service_role` key in the browser. ## Examples ### Updates a user's email. ```js const { data: user, error } = await supabase.auth.api.updateUserById( '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4', { email: 'new@email.com' } ) ``` ### Updates a user's password. ```js const { data: user, error } = await supabase.auth.api.updateUserById( '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4', { password: 'new_password' } ) ``` ### Updates a user's metadata. ```js const { data: user, error } = await supabase.auth.api.updateUserById( '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4', { user_metadata: { hello: 'world' } } ) ``` ### Updates a user's app_metadata. ```js const { data: user, error } = await supabase.auth.api.updateUserById( '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4', { app_metadata: { plan: 'trial' } } ) ``` ### Confirms a user's email address. ```js const { data: user, error } = await supabase.auth.api.updateUserById( '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4', { email_confirm: true } ) ``` ### Confirms a user's phone number. ```js const { data: user, error } = await supabase.auth.api.updateUserById( '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4', { phone_confirm: true } ) ```