API Reference
Update User
Overview
Partially update a chat user by id from the messaging app (email, role, or metadata). You can change a single field or several fields in one request.
Only these request payload fields are updated through this endpoint:
emailrolemetadata
On success, the API returns the updated user so your chat UI can refresh without an extra fetch. For the signed-in participant's own display name or avatar, use Update My Profile. For Platform panel user management, use Platform → Users → Update.
When to use this endpoint?
Use Update User when:
- A chat flow needs to correct a participant's email (
emailonly). - You assign or change a chat-side role slug (
roleonly). - Chat metadata (locale, team labels) must be added or updated (
metadataonly). - You want to apply several of the fields above in one call from the chat client.
Part of the Chat User APIs. Send only the fields you want to change. Prefer Update My Profile for self name / avatar edits.
Editable Fields
The table below lists every field this endpoint accepts. Each field can be updated on its own or combined with others.
| Field | Type | Required | Description |
|---|---|---|---|
| string | Optional | New email address for the user within this tenant. | |
| role | string | Optional | Tenant role slug (for example sales-manager). |
| metadata | object | Optional | Arbitrary key-value map merged into the user's metadata. |
Single-Field Updates
You do not need to resend the full user. Examples for one field at a time:
Email only
{
"email": "usertest@gmail.com"
}Role only
{
"role": "sales-manager"
}Metadata only
{
"metadata": {
"employeeId": "E-204"
}
}{baseUrl}/api/{apiVersion}/user/:userIdAuthentication
Required (Bearer token)
Tenant-scoped
Yes (tenant DB — requires x-client-id)
Request Headers
| Header | Value | Description |
|---|---|---|
| Authorization | Bearer <access_token> | Chat user Access Token (Bearer) for the signed-in messaging participant. |
| is-tenant | true | Targets the tenant DB ("true", needs x-client-id). |
| x-client-id | {{clientId}} | Tenant (client) id. Required when is-tenant=true. |
| Content-Type | application/json | JSON request body. |
Path Parameters
| Parameter | Example | Description |
|---|---|---|
| userId | 694b76ab3d833c4b8a3f57d8 | The target user's _id (24-char Mongo ObjectId). |
Request Payload
Combined update example changing email, role, and metadata together:
{
"email": "usertest@gmail.com",
"role": "sales-manager",
"metadata": {
"employeeId": "E-204"
}
}Success Response (HTTP 200 OK)
On success, the API returns the updated user document.
{
"success": true,
"message": "User updated successfully",
"data": {
"_id": "694b76ab3d833c4b8a3f57d8",
"name": "project user",
"email": "usertest@gmail.com",
"isActive": true,
"role": "user",
"createdAt": "2025-12-24T05:14:19.695Z",
"updatedAt": "2025-12-24T06:29:09.840Z",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2OTRiNzZhYjNkODMzYzRiOGEzZjU3ZDgiLCJlbWFpbCI6InVzZXJwM0BoZ21haWwuY29tIiwiaWF0IjoxNzY2NTU3MzE4LCJleHAiOjE3NjcxNjIxMTh9.QXEY2iGPCEzLYJ5i_GqUZOQt06gihz83pveo_MjCj-o"
},
"error": null
}Common Errors
Update fails when the token is missing, the user does not exist, or the payload is invalid.
HTTP 401 Unauthorized — No token
{
"success": false,
"message": "No token, authorization denied",
"data": null,
"error": "Unauthorized"
}HTTP 404 Not Found — User missing
{
"success": false,
"message": "User not found",
"data": null,
"error": "User not found"
}| Code | Reason |
|---|---|
| 401 Unauthorized | Access Token is missing, invalid, or expired. |
| 404 Not Found | No user exists for the given userId. |
| 400 Bad Request | Invalid email, unknown role slug, or empty update body. |
| 500 Internal Server Error | An unexpected error occurred while updating the user. |
Best Practices
- Prefer single-field updates from chat settings — smaller payloads and clearer UX.
- Use Update My Profilefor the signed-in user's name and avatar; reserve this endpoint for email / role / metadata.
- Keep metadata keys stable so people-picker filters remain correct.
- Always send tenant headers with the chat user Bearer token over HTTPS.
Chat user updated
Refresh contact cards and conversation headers from the returned document, or reload with Get User.