Update a user
Updates the user data.
Parameters
- uidREQUIREDstring
- attributesREQUIREDAdminUserAttributes
The data you want to update. This function should only be called on a server. Never expose your `service_role` key in the browser.
app_metadataOptionalobjectA 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_durationOptionalstringDetermines 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.
emailOptionalstringThe user's email.
email_confirmOptionalbooleanConfirms the user's email address if set to true. Only a service role can modify.
nonceOptionalstringThe nonce sent for reauthentication if the user's password is to be updated. Call reauthenticate() to obtain the nonce first.
passwordOptionalstringThe user's password.
phoneOptionalstringThe user's phone.
phone_confirmOptionalbooleanConfirms the user's phone number if set to true. Only a service role can modify.
user_metadataOptionalobjectA custom data object to store the user's metadata. This maps to the `auth.users.user_metadata` column. 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.
const { data: user, error } = await supabase.auth.admin.updateUserById(
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
{ email: 'new@email.com' }
)