RealTimeX
Start For Free

RealTimeX

API Documentation

IntroductionAuthenticationBase URLHeadersError codes
OverviewActivity seriesEngagementTop usersPeak hours
Sample requestsSample responsesStatus codesAppendixChangelog

API Reference

Top Users

Overview

Retrieve the highest-volume message senders in your tenant for a look-back window — ranked by message count, with basic profile fields for display.

Control the window with days and how many rows to return with limit. Ideal for leaderboards and contributor widgets.

When to use this endpoint?

Use Top Users when:

  • You need a leaderboard of the most active senders in a time range.
  • You want avatar, name, and email alongside message volume for a compact list UI.
  • You already load overview or engagement elsewhere and only need to refresh the top contributors list.
  • You prefer a lighter payload than Analytics Overview.

This endpoint requires tenant admin privileges with a valid client Access Token. End-user tokens are rejected.

Response Data

Each item in data.topUsers includes:

FieldDescription
userIdUnique id of the user (tenant user document id).
nameDisplay name for the user.
emailUser email address.
profileImageProfile image URL, or null when unset.
messageCountNumber of messages sent by this user in the selected window. Results are ordered by this field descending.
GET{baseUrl}/api/{apiVersion}/analytics/top-users?days=30&limit=10

Authentication

Required (Bearer token)

Tenant-scoped

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

Request Headers

HeaderValueDescription
AuthorizationBearer <access_token>Client Access Token with tenant admin privileges.
is-tenanttrueTargets the tenant DB ("true", needs x-client-id).
x-client-id{{clientId}}Tenant (client) id. Required when is-tenant=true.

Query Parameters

ParameterRequiredExampleDescription
daysOptional30Look-back window in days (for example 7, 30, or 90). Defaults apply when omitted.
limitOptional10Maximum number of top users to return. Default 10.

Success Response (HTTP 200 OK)

On success, the API returns the ranked list of top users for the selected window.

json
{
  "success": true,
  "message": "Top users fetched successfully",
  "data": {
    "topUsers": [
      {
        "userId": "694b...57d8",
        "name": "Will Smith",
        "email": "will.smith@example.com",
        "profileImage": null,
        "messageCount": 842
      },
      {
        "userId": "694b...8b6b",
        "name": "Gomez",
        "email": "gomez@example.com",
        "profileImage": null,
        "messageCount": 511
      }
    ]
  },
  "error": null
}

Common Errors

Top Users fails when the token is missing, expired, or lacks tenant admin privileges.

HTTP 403 Forbidden — Tenant admin required

json
{
  "success": false,
  "message": "Access denied: tenant admin privileges required",
  "data": null,
  "error": null
}

HTTP 401 Unauthorized — No token

json
{
  "success": false,
  "message": "No token, authorization denied",
  "data": null,
  "error": "Unauthorized"
}
CodeReason
401 UnauthorizedAccess Token is missing, invalid, or expired.
403 ForbiddenAccess denied: tenant admin privileges required (for example, a non-client token was used).
500 Internal Server ErrorAn unexpected error occurred while ranking top users.

Best Practices

  • Keep limit small for sidebar widgets (5–10); increase only when the UI needs a longer board.
  • Align days with other analytics widgets so rankings match the same period.
  • Fall back to initials when profileImage is null.
  • Always send tenant headers with a client Bearer token over HTTPS.

Top users ready

Render the ranked list in your leaderboard widget, then link each row to user detail using userId when your admin UI supports it.

PreviousEngagementNextPeak hours

On this page

OverviewWhen to use this endpoint?Response DataRequest HeadersQuery ParametersSuccess ResponseCommon ErrorsBest Practices