Skip to content

Comment on a post, or reply to a comment

POST
/posts/{id}/comments

Adds a comment to the post. Leave out parent_id for a top-level comment, or set it to reply to a comment on the same post; the server works out the reply’s thread and depth from that comment. The new comment is returned as saved.

A request body that isn’t valid JSON, or that gives a field a value of the wrong type, is refused with 400 before anything else is checked. Then you need to be signed in (401) and hold posts.comment (part of the Base role) or system.admin (403). body must contain more than white space (400), and it’s stored with the surrounding white space trimmed. You then need to be able to read the post: it’s the same read check GET /posts/{id} makes, without the mature settings, and a post you can’t read answers 404, as one that doesn’t exist or is deleted does. A parent_id that doesn’t exist is 404 and one on another post is 400. A reply to a deleted comment is accepted, but if that comment started its thread, the reply won’t show in the thread listing.

Last comes the post’s own setting. If comments_enabled is false, the answer is 409 with error set to comments_disabled, for replies too, and nothing from the request is saved; system.admin doesn’t get past this. The setting is read under a lock on the post in the same transaction as the insert, so once turning comments off has been saved, no comment can slip in behind it.

The comment and its activity are saved together. After that, the server tries to give the post’s author an in-app notice. For a reply, it also tries the author of the comment it answers, unless that’s the post’s author, the comment came from another instance or it has been deleted. For both top-level comments and replies, it also tries the local users you @-mention by username. You aren’t notified of your own comment. Blocks and each recipient’s in-app settings apply, and failures are only logged. Notices aren’t emailed. Sending the same request twice saves two comments. body_html comes back empty: the body isn’t turned into HTML.

id
required
string format: uuid

The post’s id.

object
body
required

The comment’s text, as plain text. It must contain more than white space, and it’s stored trimmed.

string
>= 1 characters <= 10000 characters
parent_id

The comment you’re replying to, which must be on the same post. Leave it out or send null for a top-level comment.

string format: uuid
nullable

The comment as saved.

One comment. A reply has parent_id; root_id is the first comment in its thread and depth counts how far down the thread it is (0 for a top-level comment). Annotations also carry annotation_type and annotation_data.

A comment written on this instance has author_user_ref; one received from a paired instance has peer_id and actor_uri instead. Fields with no value are left out.

object
id
required
string format: uuid
target_kind
required
string
Allowed values: post asset collection
target_id
required
string format: uuid
parent_id
string format: uuid
nullable
root_id
required
string format: uuid
depth
required
integer
author_user_ref

The local user who wrote the comment. Left out for comments received from another instance.

integer format: int64
nullable
body
required
string
body_html
required

Normally an empty string: no endpoint except the seed endpoint stores HTML here, comments from other instances don’t carry any, and the web app shows body as plain text. The seed endpoint stores its value unchecked, so don’t display this field as HTML.

string
annotation_type
string
nullable
Allowed values: point rect timestamp frame whiteboard text-range
annotation_data
object
key
additional properties
any
like_count
required
integer format: int64
edited_at
string format: date-time
nullable
created_at
required
string format: date-time
updated_at
required
string format: date-time
peer_id

The paired instance a received comment came from. Left out for comments written on this instance.

string format: uuid
nullable
actor_uri

The author’s address on their home instance, for example https://studio-b.example/users/bob. Left out for comments written on this instance.

string
nullable
display_name

The remote author’s display name. It’s often left out, even for received comments; when it is, show the host and user name from actor_uri instead.

string
nullable

Malformed request

object
error
required

Human-readable error summary

string
Example
the request could not be completed

Authentication required, missing, or invalid

object
error
required

Human-readable error summary

string
Example
the request could not be completed
Example
{
"error": "authentication required: sign in and retry with a valid session or API token"
}

Authenticated but missing required capabilities

object
error
required

Human-readable error summary

string
Example
the request could not be completed

Resource not found

object
error
required

Human-readable error summary

string
Example
the request could not be completed

The post doesn’t take comments. error is comments_disabled, and nothing from the request was saved. A client still showing a composer from an older copy of the post can hide it.

object
error
required

Human-readable error summary

string
Example
the request could not be completed