Reactions

Overview

You can react to both activities and comments. It's possible to configure any reaction types that best fit your app.

When adding reactions and the enforce_unique flag is set to true, the existing reaction of a user will be overridden with the new reaction. Use this flag if you want to ensure users have a single reaction per each comment/activity. The default value is false, in which case users can have multiple reactions.

// Add a reaction to an activity
$response = $feedsClient->addActivityReaction(
    "activity_123",
    new GeneratedModels\AddReactionRequest(
        type: 'like',
        userID: 'user123',
        // Optionally override existing reaction
        enforceUnique: true,
        custom: (object)['emoji' => '❤️']
    )
);

// Adding a reaction without triggering push notifications
$response = $feedsClient->addActivityReaction(
    "activity_123",
    new GeneratedModels\AddReactionRequest(
        type: 'like',
        userID: 'user123',
        custom: (object)['emoji' => '❤️'],
        skipPush: true
    )
);

// Add a reaction to a comment
$response = $feedsClient->addCommentReaction(
    "comment_456",
    new GeneratedModels\AddCommentReactionRequest(
        type: 'like',
        userID: 'user123',
        // Optionally override existing reaction
        enforceUnique: true,
        custom: (object)['emoji' => '👍']
    )
);

// Adding a comment reaction without triggering push notifications
$response = $feedsClient->addCommentReaction(
    "comment_456",
    new GeneratedModels\AddCommentReactionRequest(
        type: 'like',
        userID: 'user123',
        custom: (object)['emoji' => '👍'],
        skipPush: true
    )
);

// Delete activity reaction
$response = $feedsClient->deleteActivityReaction(
    "activity_123",
    "like",
    "user123"
);

Overview of the reaction model

FeedsReactionResponse

NameTypeDescriptionConstraints
activity_idstringID of the activity that was reacted toRequired
comment_idstringID of the comment that was reacted to-
created_atnumberWhen the reaction was createdRequired
customobjectCustom data for the reaction-
typestringType of reactionRequired
updated_atnumberWhen the reaction was last updatedRequired
userUserResponseUser who created the reactionRequired

By default creating a reaction doesn't create an activity. Pass create_notification_activity: true to add a notification to the reacted-to user's notification feed — see Reaction notification creation timing (added June 23, 2026). The response includes notification_accepted and notification_task_id; notification_created is deprecated and mirrors notification_accepted.

When you read a feed the reactions are included. Here's an example:

// Get feed data with reactions
$feedResponse = $feedsClient->getOrCreateFeed(
    "user",
    "sara",
    new GeneratedModels\GetOrCreateFeedRequest(
        userID: "sara"
    )
);

// Access reaction data from activities
$activities = $feedResponse->getData()->activities;
if (!empty($activities)) {
    $firstActivity = $activities[0];
    echo "Own reactions: " . json_encode($firstActivity->ownReactions ?? []) . "\n";
    echo "Latest reactions: " . json_encode($firstActivity->latestReactions ?? []) . "\n";
    echo "Reaction groups: " . json_encode($firstActivity->reactionGroups ?? []) . "\n";
}

// Query reactions to a specific activity
$response = $feedsClient->queryActivityReactions(
    "activity_123",
    new GeneratedModels\QueryActivityReactionsRequest(
        limit: 10,
        filter: (object)['reaction_type' => 'like']
    )
);

Querying Reactions

You can query reactions to both activities and comments. Here are some examples:

// Query reactions to a specific activity
$response = $feedsClient->queryActivityReactions(
    "activity_123",
    new GeneratedModels\QueryActivityReactionsRequest(
        limit: 10,
        filter: (object)['reaction_type' => 'like']
    )
);

// Handle activity reactions
$reactions = $response->getData()->reactions;
foreach ($reactions as $reaction) {
    echo "Reaction: " . $reaction->type . " by " . $reaction->user->id . "\n";
}

// Query reactions to a specific comment
$response = $feedsClient->queryCommentReactions(
    $commentId,
    new GeneratedModels\QueryCommentReactionsRequest(
        limit: 10,
        filter: (object)['reaction_type' => 'like']
    )
);

// Handle comment reactions
$reactions = $response->getData()->reactions;
foreach ($reactions as $reaction) {
    echo "Comment reaction: " . $reaction->type . " by " . $reaction->user->id . "\n";
}

Batch query activity reactions

batchQueryActivityReactions fetches a single user's reactions across a whole page of activities in one call, so you can merge own_reactions back onto a cached page without calling query reactions once per activity. Pass up to 100 activity IDs per request. The response contains reaction rows only (no activity payloads) and supports the same filter, sort, and pagination options as the single-activity query.

On a client-side connection the returned reactions are always the connected user's. Server-side, pass user_id to choose whose reactions to fetch.

const response = await client.batchQueryActivityReactions({
  activity_ids: activities.map((activity) => activity.id),
  filter: { reaction_type: "like" },
});

console.log(response.reactions);

Reaction queryable built-in fields

Both batchQueryActivityReactions and batchQueryCommentReactions accept these filter fields.

nametypedescriptionsupported operationsexample
reaction_typestring or list of stringsThe type of reaction$in, $eq{ reaction_type: { $in: [ 'like', 'heart', 'thumbs_up' ] } }
user_idstring or list of stringsThe ID of the user who created the reaction$in, $eq{ user_id: { $eq: 'user_123' } }
created_atstring, must be formatted as an RFC3339 timestampThe time the reaction was created$eq, $gt, $gte, $lt, $lte{ created_at: { $gte: '2023-12-04T09:30:20.45Z' } }

Batch query comment reactions

batchQueryCommentReactions is the comment counterpart of batch query activity reactions. It fetches a single user's reactions across up to 100 comments in one call, returning reaction rows only (no comment payloads). Use it to hydrate own_reactions for a whole comment thread without a request per comment. It accepts the same filter fields, sort, and pagination options.

As with activities, a client-side connection returns the connected user's reactions; server-side, pass user_id.

const response = await client.batchQueryCommentReactions({
  comment_ids: comments.map((comment) => comment.id),
  filter: { reaction_type: "like" },
});

console.log(response.reactions);