Skip to main content

Create a Comment

This endpoint creates a comment.

info

One of discussion , post or status parameter is required in every request (first-level or nested comment creation).

The parent parameter is required only for nested comments.

The in_reply_to parameter is required only for create a reference in the nested comments (simulation of three levels of nesting).

info

This operation requires authentication

HTTP Request

POST /api/v2/comment/

Parameters

NameInTypeRequiredDescription
» discussionbodyintegertrueId of the Discussion
» postbodyintegertrueId of the Post
» statusbodyintegertrueId of the Status
» parentbodyinteger¦nullfalseId of a Comment, used for creating nested comments
» in_reply_tobodyinteger¦nullfalseId of a Comment, used for reply in nested comments
» textbodystringtruetext for the Comment, html format, it can contain some mentions

Example Body Parameters

{
"discussion": "integer",
"parent": "integer",
"in_reply_to": "integer",
"text": "string"
}

Example Request

const inputBody = '{
"discussion": "integer",
"parent": "integer",
"in_reply_to": "integer",
"text": "string"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization: 'Bearer {access_token}'
};

fetch('/api/v2/comment/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});

Responses

StatusMeaningDescriptionSchema
201CreatedResponse status codeComment

Example responses

{
"id": "integer",
"author": {User},
"added_at": "string",
"last_edited_at": "string",
"html": "string",
"summary": "string",
"deleted": "boolean",
"collapsed": "boolean",
"parent": "integer",
"in_reply_to": "integer",
"comment_count": "integer",
"vote_count": "integer",
"reactions_count": [{Reaction}],
"flag_count": "integer",
"post": {
"id": "integer",
"slug": "string"
},
"latest_comments": [{CommentSummary}],
"type": "string",
"voted": "boolean",
"reaction": {Reaction}
}