RealTimeX
Start For Free

RealTimeX

API Documentation

IntroductionAuthenticationBase URLHeadersError codes
List usersLoginGet userUpdate userDelete userGet my profileUpdate my profileBlock / unblock
Sample requestsSample responsesStatus codesAppendixChangelog

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:

  • email
  • role
  • metadata

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 (email only).
  • You assign or change a chat-side role slug (role only).
  • Chat metadata (locale, team labels) must be added or updated (metadata only).
  • 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.

FieldTypeRequiredDescription
emailstringOptionalNew email address for the user within this tenant.
rolestringOptionalTenant role slug (for example sales-manager).
metadataobjectOptionalArbitrary 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

json
{
  "email": "usertest@gmail.com"
}

Role only

json
{
  "role": "sales-manager"
}

Metadata only

json
{
  "metadata": {
    "employeeId": "E-204"
  }
}
PUT{baseUrl}/api/{apiVersion}/user/:userId

Authentication

Required (Bearer token)

Tenant-scoped

Yes (tenant DB — requires x-client-id)

Request Headers

HeaderValueDescription
AuthorizationBearer <access_token>Chat user Access Token (Bearer) for the signed-in messaging participant.
is-tenanttrueTargets the tenant DB ("true", needs x-client-id).
x-client-id{{clientId}}Tenant (client) id. Required when is-tenant=true.
Content-Typeapplication/jsonJSON request body.

Path Parameters

ParameterExampleDescription
userId694b76ab3d833c4b8a3f57d8The target user's _id (24-char Mongo ObjectId).

Request Payload

Combined update example changing email, role, and metadata together:

json
{
  "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.

json
{
  "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

json
{
  "success": false,
  "message": "No token, authorization denied",
  "data": null,
  "error": "Unauthorized"
}

HTTP 404 Not Found — User missing

json
{
  "success": false,
  "message": "User not found",
  "data": null,
  "error": "User not found"
}
CodeReason
401 UnauthorizedAccess Token is missing, invalid, or expired.
404 Not FoundNo user exists for the given userId.
400 Bad RequestInvalid email, unknown role slug, or empty update body.
500 Internal Server ErrorAn 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.

PreviousGet userNextDelete user

On this page

OverviewWhen to use this endpoint?Editable FieldsSingle-Field UpdatesRequest HeadersPath ParametersRequest PayloadSuccess ResponseCommon ErrorsBest Practices