> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Comment Reaction

> Add or update a reaction on a comment

Adds a reaction of the specified type to a comment. If the user already has a reaction on this comment, it is replaced with the new type. The comment's `reactionCounts` map is updated accordingly. Sending the reaction the user already has changes nothing: the response is the same `200` with the comment, counts stay as they are, and no notification is sent.

**Authentication required.**

## Path Parameters

<ParamField path="commentId" type="string" required>
  The UUID of the comment to react to.
</ParamField>

## Body Parameters

<ParamField body="reactionType" type="string" required>
  The type of reaction to add. One of: `upvote`, `downvote`, `like`, `love`, `wow`, `sad`, `angry`, `funny`.
</ParamField>

<ParamField body="userId" type="string">
  The user the reaction is attributed to. **Service or master key only**, and required with one — a key has no user of its own, so leaving it out returns `400 comment/missing-user-id`. A user token always reacts as itself: naming a different user returns `403 comment/unauthorized`.

  A `userId` that doesn't match a user returns `404 comment/user-not-found`.
</ParamField>

## Blocks

When the `moderation` bundle is installed:

* **If the reacting user blocked the comment's author**, the reaction is allowed — the block is their own choice. The author gets no reaction notification for it; if the reaction completes a milestone, the milestone notification is still sent, with the reacting user left out of its `lastThreeUsers`.
* **If the comment's author blocked the reacting user** (or both blocked each other), the request returns `404 comment/not-found`. These comments are marked [`isUnavailable`](/v8/data-models/comment#blocked-authors) in threads.
* **If the author of the comment's entity blocked the reacting user**, the request returns `404 comment/not-found` — for every comment on that entity, the reacting user's own included.

A refused reaction looks exactly like a missing comment and changes nothing.

## Deleted and removed comments

A comment its author deleted can't be reacted to: the request returns `403 comment/deleted` and changes nothing. This applies to everyone, including the comment's author, and covers changing an existing reaction to another type too.

Reacting to a moderator-removed comment returns `404 comment/not-found` — for everyone, including the removed comment's author.

The `403` is only returned for a comment the reacting user can see. A deleted comment that a block hides from them (see [Blocks](#blocks)) returns `404 comment/not-found`, like any other.

Reactions already on a deleted or removed comment can still be taken off with [Remove Comment Reaction](/v8/api-reference/comments/remove-reaction).

## Response

Returns the updated [Comment](/v8/data-models/comment) object with the new `reactionCounts` map, shaped for the reacting user (with `isAuthorBlocked` and `isUnavailable` flags), the same way [Fetch Comment](/v8/api-reference/comments/fetch-comment) returns it.

## Error Responses

<AccordionGroup>
  <Accordion title="Invalid Params — 400">
    Returned when `commentId` isn't a valid UUID.

    ```json theme={null}
    { "error": "commentId: Invalid UUID format", "code": "comment/invalid-params" }
    ```
  </Accordion>

  <Accordion title="Invalid Body — 400">
    Returned when `reactionType` is missing or isn't one of the eight types, or when `userId` isn't a valid UUID.

    ```json theme={null}
    {
      "error": "reactionType: Invalid option: expected one of \"upvote\"|\"downvote\"|\"like\"|\"love\"|\"wow\"|\"sad\"|\"angry\"|\"funny\"",
      "code": "comment/invalid-body"
    }
    ```
  </Accordion>

  <Accordion title="Acting as another user — 403">
    Returned when a request authenticated with a user token sends a `userId` other than that user's own ID.

    ```json theme={null}
    { "error": "Unauthorized", "code": "comment/unauthorized" }
    ```
  </Accordion>

  <Accordion title="Missing User — 400">
    Returned when a service or master key sends no `userId`.

    ```json theme={null}
    { "error": "Missing user ID", "code": "comment/missing-user-id" }
    ```
  </Accordion>

  <Accordion title="User Not Found — 404">
    Returned when a service or master key names a `userId` that doesn't exist.

    ```json theme={null}
    { "error": "User not found", "code": "comment/user-not-found" }
    ```
  </Accordion>

  <Accordion title="Not Found — 404">
    Returned when the comment doesn't exist, when a moderator removed it, or when a block refuses the reaction (see [Blocks](#blocks)).

    ```json theme={null}
    { "error": "Comment not found.", "code": "comment/not-found" }
    ```
  </Accordion>

  <Accordion title="Comment Deleted — 403">
    Returned when the comment was deleted by its author (see [Deleted and removed comments](#deleted-and-removed-comments)).

    ```json theme={null}
    { "error": "This comment was deleted and can't be reacted to.", "code": "comment/deleted" }
    ```
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.