Skip to main content
Comments are threaded discussions attached to entities. The comments module lets you create, fetch, update, and delete comments, and manage reactions on them. All actions are performed on behalf of the logged-in user.

createComment

Creates a comment on an entity. Optionally a reply, with a GIF, mentions, attachments, or metadata.
string
required
The Sublay entity ID the comment belongs to.
string
Your application’s identifier for this comment.
string
The comment’s text content.
GifData | null
An optional GIF attached to the comment.
Mention[]
User mentions embedded in the comment.
string | null
The ID of the parent comment when this is a reply.
string
The ID of another comment this comment references.
Record<string, any>[]
File or media attachments.
Record<string, any>
Arbitrary public metadata.
Returns — Promise<Comment> When the server refuses the comment, the call rejects with its error — among them 403 comment/parent-deleted and 403 comment/parent-removed for a reply to a deleted or removed comment, 403 comment/referenced-deleted and 403 comment/referenced-removed for a quote of one, and 409 comment/foreign-id-taken for a foreignId already in use. See Create Comment → Error Responses for the full list.

fetchComment

Fetches a single comment by its ID.
string
required
The Sublay comment ID.
string
Comma-separated list of associations to populate.
Returns — Promise<Comment>

fetchCommentByForeignId

Fetches a comment by your application’s own identifier.
string
required
Your application’s comment identifier.
string
Comma-separated list of associations to populate.
Returns — Promise<Comment>

updateComment

Updates a comment’s content.
string
required
The Sublay comment ID to update.
string
required
The new content for the comment.
Returns — Promise<Comment>

deleteComment

Deletes a comment.
string
required
The Sublay comment ID to delete.
Returns — Promise<void>

fetchManyComments

Fetches one level of a comment thread, cursor-paginated: an entity’s top-level comments (entityId) or a comment’s direct replies (parentId). One of the two is required. Optionally nests a few levels of replies inside each returned comment. See Fetch Many Comments for the full contract — placeholders, block flags and the request size limit.
For a user’s comments across entities, use users.fetchCommentsByUserId.
string
Fetch this entity’s top-level comments. Required unless parentId is passed.
string
Fetch this comment’s direct replies. Required unless entityId is passed.
number
How many comments at the level being fetched. Server default 10, max 100.
string | null
pagination.nextCursor from the previous response, passed as returned. Omit it, or pass null, for the first page. Send the same sortBy, sortDir and sortByReaction as the request that returned it.
"createdAt" | "top" | "controversial"
Sort for the level being fetched. "top" ranks by the raw count of sortByReaction. Server default "createdAt". "new" / "old" are deprecated aliases for "createdAt" — the server still accepts them but responds with a deprecation header.
"asc" | "desc"
Applies to every sort. Server default "desc".
ReactionType
With sortBy: "top" only: the reaction to rank by. Server default "upvote".
number
Levels of replies to nest under each returned comment (0–5). Server default 0.
number
Replies per comment in the nested levels (at least 1). Server default 3.
"createdAt" | "top" | "controversial"
Sort for the nested levels. Defaults to sortBy.
"asc" | "desc"
Sort direction for the nested levels. Defaults to sortDir.
ReactionType
The reaction the nested levels rank by, when their sort is "top".
"user" | "grants" | ("user" | "grants")[]
Related data to populate, at every level.
Returns — Promise<CursorPaginatedResponse<Comment>> — { data, pagination: { nextCursor, hasMore } }. With replyDepth above 0, each comment carries nested replies in the same shape.

addReaction

Adds the logged-in user’s reaction to a comment and returns the full populated comment.
string
required
The Sublay comment ID.
ReactionType
required
One of: "upvote", "downvote", "like", "love", "wow", "sad", "angry", "funny".
Returns — Promise<Comment>

removeReaction

Removes the logged-in user’s reaction from a comment and returns the full populated comment.
string
required
The Sublay comment ID.
Returns — Promise<Comment>

fetchReactions

Fetches a paginated list of reactions on a comment, optionally filtered by reaction type.
string
required
The Sublay comment ID.
ReactionType
Filter to a specific reaction type.
number
Page number (1-indexed).
number
Results per page.
string
Sort direction: "asc" or "desc".
Returns — Promise<{ data: Reaction[]; pagination: { page: number; limit: number; total: number; totalPages: number; hasMore: boolean } }>

getUserReaction

Gets the logged-in user’s reaction on a comment. Returns null if there is no reaction.
string
required
The Sublay comment ID.
Returns — Promise<{ reactionType: ReactionType | null }>. Rejects with 404 comment/not-found when the comment doesn’t exist, or is on an entity whose author has blocked the user (the user’s own comments excepted).