RealTimeX
Start For Free

RealTimeX

API Documentation

IntroductionAuthenticationBase URLHeadersError codes
Get profileUpdate profileChange passwordList conversationsConversation metadata keysGet conversationConversation messagesUpdate conversationDelete conversationBulk delete conversationsList messagesMessage metadata keysUpdate messageDelete messageBulk delete messagesList usersUser metadata keysGet userUpdate userDelete userBulk delete users
Sample requestsSample responsesStatus codesAppendixChangelog

API Reference

Update User

Overview

Partially update a tenant user’s profile in the client workspace. This endpoint supports independent updates — you can change a single field or several fields in one request.

Only these request payload fields can be updated:

  • name
  • email
  • role
  • isActive
  • metadata

Other user properties (online status, last seen, and similar) are not editable through this endpoint. On success, the API returns the updated user document so your UI can refresh without an extra fetch.

When to use this endpoint?

Use Update User when:

  • An admin renames a user (name only).
  • You need to change a user’s email (email only).
  • You assign or change a tenant role slug (role only).
  • You activate or deactivate a user (isActive only).
  • Custom metadata keys need to be added or updated for filtering (metadata only).

At least one editable field must be present in the request body. Send only the fields you want to change — unsupported fields are ignored.

Editable Fields

The table below lists every field this endpoint accepts. Each field can be updated on its own (single-field update) or combined with others.

FieldTypeRequiredDescription
namestringOptionalDisplay name of the user. Can be sent alone to rename the user.
emailstringOptionalEmail address for the user. Must be unique within the tenant. Returns 409 Conflict if already used by another user.
rolestringOptionalTenant role slug (for example user, moderator, admin). Must be a valid role for the tenant or the API returns 400 Bad Request.
isActivebooleanOptionalWhether the user account is active. Send alone to activate or deactivate without changing other fields.
metadataobjectOptionalCustom key/value data (for example department or team). Send alone to update metadata without changing profile fields.

All fields above are optional individually, but the body must include at least one of them.

Single-Field Updates

Because this endpoint is partial, each editable value can be updated independently. Use these patterns when your UI changes one setting at a time.

Update name only

json
{
  "name": "Will Smith"
}

Update email only

json
{
  "email": "will.smith@example.com"
}

Update role only

json
{
  "role": "moderator"
}

Update active status only

json
{
  "isActive": false
}

Update metadata only

json
{
  "metadata": {
    "department": "support"
  }
}
PATCH{baseUrl}/api/{apiVersion}/client/users/:userId

Authentication

Required (Bearer token)

Tenant-scoped

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

Request Headers

HeaderValueDescription
AuthorizationBearer <access_token>Access Token from Login Client or Register Client.
is-tenanttrueTargets the tenant DB ("true", needs x-client-id).
x-client-id{{clientId}}Tenant (client) id. Uses the {{clientId}} variable.
Content-Typeapplication/jsonRequired when sending a JSON request body.

Path Parameters

ParameterExampleDescription
userIdstringUser _id (24-char Mongo ObjectId) of the user to update.

Request Payload

Example combining multiple editable fields in one request. You do not need to send every field — omit anything you are not changing.

json
{
  "name": "Will Smith",
  "email": "will.smith@example.com",
  "role": "moderator",
  "isActive": true,
  "metadata": {
    "workspaceId": "c1"
  }
}

Success Response (HTTP 200 OK)

When the update succeeds, the API returns the updated user document with the new field values merged in.

json
{
  "success": true,
  "message": "User updated successfully",
  "data": {
    "_id": "699f...645d",
    "name": "Will Smith",
    "email": "will.smith@example.com",
    "role": "moderator",
    "isActive": true,
    "isOnline": false,
    "profileImage": "https://example.com/profile-image.png",
    "metadata": {
      "workspaceId": "c1"
    },
    "lastSeen": "2026-07-09T10:58:31.000Z",
    "createdAt": "2026-05-14T08:22:10.000Z",
    "updatedAt": "2026-07-09T11:30:00.000Z",
    "__v": 4
  },
  "error": null
}

Common Errors

Updates fail when the email conflicts, the role is invalid, nothing editable is provided, or authentication is missing.

HTTP 400 Bad Request — Invalid role

json
{
  "success": false,
  "message": "Invalid role",
  "data": null,
  "error": "Invalid role"
}

HTTP 409 Conflict — Email already in use

json
{
  "success": false,
  "message": "Email already in use by another user",
  "data": null,
  "error": "Email already in use by another user"
}
CodeReason
400 Bad RequestInvalid role, invalid field values, or no editable fields provided.
401 UnauthorizedAccess Token is missing, invalid, or expired.
404 Not FoundUser not found for the given userId.
409 ConflictEmail already in use by another user.
500 Internal Server ErrorAn unexpected error occurred while updating the user.

Best Practices

  • Prefer single-field updates when the UI edits one control at a time (name, email, role, active status, or metadata).
  • Never send an empty body — always include at least one of name, email, role, isActive, or metadata.
  • Validate email uniqueness in the UI when possible to avoid 409 Conflict.
  • Assign only role slugs that exist for the tenant to avoid 400 Bad Request.
  • Keep metadata keys consistent so list filters with metadata.<key> remain reliable.
  • Always set Content-Type: application/json with tenant headers and a Bearer token.

User updated

Refresh your list or detail view with the returned document, or call Get User Detail again if other screens cache an older copy.

PreviousGet userNextDelete user

On this page

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