Link copied to clipboard!
Mobile navigation button - closed state

Activity API

The activity API offers information about user comments at specific locations in your app, letting you build custom activity UI indicators such as unread badge counts.

Thread Activity Summary

Through this API you can observe a summary of the activity happening on a specific location in your app.

Information available through the thread activity summary API
total number the total number of threads at the location, both resolved and unresolved
unread number the number of threads that have messages the current user hasn't seen yet
resolved number the number of threads that are resolved

Example React usage

You can access the thread activity summary using the useCordThreadActivitySummary hook.

Initially this hook will return undefined while the data is loading from our API. Your component will re-render once the summary data becomes available, then every time the numbers change (a new thread is created, the user has new unread threads, etc).

import { useCordThreadActivitySummary } from '@cord-sdk/react';

function App() {
  const summary = useCordThreadActivitySummary({
    page: "document_details",
    document_id: "123",

  return (
      {!summary && "Loading..."}

      {summary && (
        <p>Total threads: {}</p>
        <p>Unread threads: {summary.unread}</p>
        <p>Resolved threads: {summary.resolved}</p>

Example plain JavaScript usage

If you don’t use React, you can still access this information through the JavaScript API available on window.CordSDK.activity.

To start observing activity, use the observeThreadSummary function, providing the location and a callback function. The callback will be called once with the current activity summary, as well as subsequently every time the numbers change (a new thread is created, the user has new unread threads, etc).

// start observing thread activity summary on a location
const ref = window.CordSDK.activity.observeThreadSummary({
  page: "document_details",
  document_id: "123",
}, (summary) => {
  // received an update!
  console.log("Total threads",;
  console.log("Unread threads", summary.unread);
  console.log("Resolved threads", summary.resolved);
// stop observing


type ThreadActivitySummary = {
  total: number;
  unread: number;
  resolved: number;

type ThreadActivitySummaryUpdateCallback = (
  summary: ThreadActivitySummary,
) => unknown;

interface ICordActivitySDK {
    location: Location,
    callback: ThreadActivitySummaryUpdateCallback,
  ): ListenerRef;
  unobserveThreadSummary(ref: ListenerRef): boolean;

function useCordThreadActivitySummary(
  location: Location,
): ThreadActivitySummary | undefined;