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

List Messages

Overview

Retrieve a paginated list of messages in the current tenant workspace.

Filter by conversation, sender, message type, text search, or custom metadata. The response includes message summaries with sender details and pagination metadata for inbox views, moderation tools, and history browsers.

When to use this endpoint?

Use List Messages when:

  • You need to display messages in an admin inbox, moderation queue, or history table.
  • You want to scope results to a conversation, sender, or message type.
  • You are searching message content or filtering with metadata.<key> values.
  • You need pagination details such as total count and next/previous page flags.
GET{baseUrl}/api/{apiVersion}/client/messages?page=1&limit=10

Authentication

Required (Bearer token)

Tenant-scoped

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

Request Headers

HeaderValueDescription
is-tenanttrueTargets the tenant DB ("true", needs x-client-id) or the root DB ("false", e.g. client register/create).
x-client-id{{clientId}}Tenant (client) id. Required when is-tenant=true. Uses the {{clientId}} variable.

Query Parameters

ParameterExampleDescription
page1Page number, 1-based. Default 1.
limit10Page size — items per page. Default 10.
conversationId—Conversation _id to scope results to (24-char Mongo ObjectId).
sender—Filter by sender userId (24-char Mongo ObjectId).
typetextFilter by type (message type: text / image / file).
search—Case-insensitive text search (input is regex-escaped, safe). Matches this endpoint’s searchable fields.
metadata.workspaceIdc1Filter on custom metadata. Matches metadata.workspaceId exactly — use any metadata.<yourKey>=value your app stores.

Success Response (HTTP 200 OK)

On success, the API returns a paginated list of messages for the tenant.

json
{
  "success": true,
  "message": "Messages fetched successfully",
  "data": {
    "list": [
      {
        "_id": "6a59...aa9e",
        "conversationId": "6a3c...155e",
        "sender": {
            "_id": "6a35...daa8",
            "name": "chat1"
        },
        "isSystemMessage": false,
        "content": "Gelato is the best ice cream in the world",
        "type": "text",
        "isEdited": false,
        "isForwarded": false,
        "status": "read",
        "readBy": [
            "6a3c...14fe"
        ],
        "starredBy": [],
        "deletedFor": [],
        "isDeletedForEveryone": false,
        "attachments": [],
        "reactions": [],
        "createdAt": "2026-07-17T08:06:36.626Z",
        "updatedAt": "2026-07-17T08:06:41.697Z",
        "__v": 0
      }
    ],
    "pagination": {
      "currentPage": 1,
      "totalCount": 1,
      "hasNextPage": true,
      "hasPreviousPage": false,
      "pageSize": 10
    }
  },
  "error": null
}

Common Errors

HTTP 200 OK means the list was fetched successfully. Requests fail when tenant headers or authentication are missing or invalid.

CodeReason
400 Bad RequestRequired headers are missing or query parameters are invalid.
401 UnauthorizedAccess Token is missing, invalid, or expired.
500 Internal Server ErrorAn unexpected error occurred while fetching messages.

Best Practices

  • Always send is-tenant: true and a valid x-client-id for tenant-scoped message lists.
  • Keep limit reasonable for UI tables; use pagination.hasNextPage to load more pages.
  • Prefer conversationId, search, and typed filters over fetching all messages client-side.
  • Discover available metadata keys with Get Message Metadata Keys before building metadata.<key> filters.
  • Refresh the list after update, delete, or bulk-delete operations so the UI stays in sync.

Ready to browse messages

With a valid Access Token and tenant headers, you can list messages and update or remove a single record using the returned _id. Continue with Update Message or Delete Message.

PreviousBulk delete conversationsNextMessage metadata keys

On this page

OverviewWhen to use this endpoint?Request HeadersQuery ParametersSuccess ResponseCommon ErrorsBest Practices