---
title: "Create a comment or a reply"
method: POST
path: "/api/sites/{slug}/comments"
tags: ["site-controller"]
---

# Create a comment or a reply

`POST /api/sites/{slug}/comments`

## Request

- Base URL: `https://api.pagegoat.com`
- URL: `https://api.pagegoat.com/api/sites/{slug}/comments`
- Auth: HTTP bearer

## Path parameters

- `slug` string, required

## Request body

- CreateCommentRequest: A new comment, or a reply when `parentId` is set. Supply `anchor` to record where on the page the comment belongs; `anchorText` alone is accepted for compatibility and is treated as a quote-only anchor.
  - `body` string, required: The comment text. Required; blank is rejected with 400.
  - `anchorText` string, nullable: The selected text, when you have no full anchor to send. Ignored if `anchor.text` is present.
  - `anchor` CommentAnchor, nullable, required: Where on the page a comment was left. Several redundant descriptions of one spot, because each survives a different kind of edit. Resolved in the browser, never by the API. All fields are optional; `text` alone is a usable anchor.
    - `text` string, required: The selected text, whitespace-normalized. The primary selector.
    - `prefix` string, nullable: Roughly 48 characters of page text immediately before the selection, used to tell repeated quotes apart.
    - `suffix` string, nullable: Roughly 48 characters immediately after the selection.
    - `start` string, nullable: CSS path to the element holding the selection's first character.
    - `startOffset` integer, nullable: Offset of that character within the start element's own text.
    - `end` string, nullable: CSS path to the element holding the selection's last character.
    - `endOffset` integer, nullable: Offset one past that character, within the end element's own text.
    - `page` string, nullable: Page within a multi-file site: "/" for the entrypoint, otherwise a path relative to the site root.
    - `version` integer, nullable: Site version the selection was made against, so a stale anchor can say which version it described.
  - `parentId` string, uuid, nullable: Thread root, to post a reply. Omit for a top-level comment. Replying to a reply is rejected with 400.

## Response `201`

The created comment.

## Other responses

- `400`: Blank body, or a reply to a reply.
- `403`: Commenter role required.
- `423`: Commenting is disabled on this site.

---

[API](https://skmtc.dev/pagegoat/apis/pagegoat-api.md) · [All operations](https://skmtc.dev/pagegoat/apis/pagegoat-api/llms.txt) · [OpenAPI document](https://skmtc.dev/pagegoat/apis/pagegoat-api/revisions/3e87219680af?raw)
