> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Update User

> Update a user's profile fields, including avatar and banner images

Updates one or more profile fields for the specified user. The requesting user must own the account, or use a service key to update any user.

Supports direct image uploads for the avatar and banner via `multipart/form-data`. Uploaded images are processed, stored in Supabase, and the old files are automatically cleaned up after a successful update.

> [!NOTE]
>
> Send `application/json` for text-only updates. Use `multipart/form-data`
> when uploading image files.

## Authentication

Requires a valid user auth token. The authenticated user must match `:userId`, or the request must carry a service token.

## Path Parameters

**userId** `string` *required*

The Sublay user ID (UUID) to update.

## Body Parameters

All fields are optional. Only the fields provided are updated.

**name** `string`

Display name.

**username** `string`

New username. Automatically lowercased and sanitized. Returns 409 if already
taken by another user.

**avatar** `string`

URL of the user's avatar image. Ignored if `avatarFile` is also provided.

**bio** `string`

Short bio text.

**birthdate** `string`

ISO 8601 datetime string for the user's date of birth (e.g. `"1990-06-15T00:00:00.000Z"`).

**location** `object`

Geographic location stored as a PostGIS point.

**properties**

**latitude** `number` *required*

Latitude between -90 and 90.

**longitude** `number` *required*

Longitude between -180 and 180.

**metadata** `object`

Public custom key-value data. Replaces the existing value.

**secureMetadata** `object`

Custom key-value data. No API response returns it, to this user or anyone else; your backend receives it in webhooks. The user can write it themselves, so don't store anything your app needs to trust here. Replaces the
existing value.

**avatarFile** `file`

Avatar image file (multipart). Maximum 50 MB. Must be a valid image.
Requires `avatarFile.options` to be present in the same request.

**bannerFile** `file`

Banner image file (multipart). Maximum 50 MB. Must be a valid image.
Requires `bannerFile.options` to be present in the same request.

## Response

On success, returns HTTP `200` with the updated user's authenticated profile:

**id** `string`

Unique user ID (UUID).

**foreignId** `string | null`

External identifier from your system.

**role** `string`

User role (e.g., `"visitor"`).

**email** `string | null`

User's email address.

**name** `string | null`

Updated display name.

**username** `string | null`

Updated username.

**avatar** `string | null`

Avatar URL.

**bio** `string | null`

Bio text.

**metadata** `object | null`

Public custom key-value data.

**reputation** `number | null`

Reputation score.

**isVerified** `boolean | null`

Whether the user's email has been verified.

**isActive** `boolean | null`

Whether the user account is active.

**lastActive** `string | null`

ISO timestamp of the user's last activity.

**suspensions** `array`

Active suspensions on the account.

**avatarFile** `object | null`

Processed avatar image with variants.

**bannerFile** `object | null`

Processed banner image with variants.

**authMethods** `string[]`

Active auth methods (e.g., `["password", "google"]`).

**createdAt** `string`

ISO timestamp of account creation.

> [!NOTE]
>
> When `name`, `username`, or `bio` changes, the user's semantic search
> embedding is automatically updated asynchronously.

## Error Responses

> [accordion] Not Authorized — 403
>
> ```json theme={null}
> {
>   "error": "Not authorized to update this user.",
>   "code": "user/not-authorized"
> }
> ```

> [accordion] User Not Found — 404
>
> ```json theme={null}
> {
>   "error": "User not found",
>   "code": "user/not-found"
> }
> ```

> [accordion] File Too Large — 413
>
> ```json theme={null}
> {
>   "message": "Avatar image exceeds 50MB limit.",
>   "code": "user/file-too-large"
> }
> ```

> [accordion] Invalid Image — 422
>
> ```json theme={null}
> {
>   "message": "Avatar file is not a valid image: ...",
>   "code": "user/invalid-image"
> }
> ```

> [accordion] Missing Image Options — 400
>
> ```json theme={null}
> {
>   "message": "Image options are required when uploading an avatar. Must include mode property.",
>   "code": "user/missing-image-options"
> }
> ```

> [accordion] Validation Failed — 400
>
> ```json theme={null}
> {
>   "error": "User validation failed",
>   "code": "user/validation-failed"
> }
> ```

> [accordion] Invalid Params — 400
>
> ```json theme={null}
> {
>   "error": "...",
>   "code": "user/invalid-params"
> }
> ```

## See Also

* [`useUserActions` hook](https://docs.sublay.io/v7/hooks/user/use-user-actions) — `updateUser`
* [Storage: Upload Image](https://docs.sublay.io/v7/api-reference/storage/upload-image.md)
* [User data model](https://docs.sublay.io/v7/data-models/user.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.