`/wp/v2/comments`

Namespace: wp/v2
Route: /wp/v2/comments

Routes

  • Collection: /wp/v2/comments
  • Single: /wp/v2/comments/{id}

HTTP Methods

Collection methods: GET, POST, GET, POST

Single methods: GET, POST, PUT, PATCH, DELETE, GET, POST, PUT, PATCH, DELETE

Request Parameters

Collection GET

ParameterTypeRequiredDefaultDescription
contextstringfalseviewScope under which the request is made; determines fields present in response.
pageintegerfalse1Current page of the collection.
per_pageintegerfalse10Maximum number of items to be returned in result set.
searchstringfalseLimit results to those matching a string.
afterstringfalseLimit response to comments published after a given ISO8601 compliant date.
authorarrayfalseLimit result set to comments assigned to specific user IDs. Requires authorization.
author_excludearrayfalseEnsure result set excludes comments assigned to specific user IDs. Requires authorization.
author_emailstringfalseNoneLimit result set to that from a specific author email. Requires authorization.
beforestringfalseLimit response to comments published before a given ISO8601 compliant date.
excludearrayfalse[]Ensure result set excludes specific IDs.
includearrayfalse[]Limit result set to specific IDs.
offsetintegerfalseOffset the result set by a specific number of items.
orderstringfalsedescOrder sort attribute ascending or descending.
orderbystringfalsedate_gmtSort collection by comment attribute.
parentarrayfalse[]Limit result set to comments of specific parent IDs.
parent_excludearrayfalse[]Ensure result set excludes specific parent IDs.
postarrayfalse[]Limit result set to comments assigned to specific post IDs.
statusstringfalseapproveLimit result set to comments assigned a specific status. Requires authorization.
typestringfalsecommentLimit result set to comments assigned a specific type. Requires authorization.
passwordstringfalseThe password for the post if it is password protected.

Collection POST

ParameterTypeRequiredDefaultDescription
authorintegerfalseThe ID of the user object, if author was a user.
author_emailstringfalseEmail address for the comment author.
author_ipstringfalseIP address for the comment author.
author_namestringfalseDisplay name for the comment author.
author_urlstringfalseURL for the comment author.
author_user_agentstringfalseUser agent for the comment author.
contentobjectfalseThe content for the comment.
datestringfalseThe date the comment was published, in the site’s timezone.
date_gmtstringfalseThe date the comment was published, as GMT.
parentintegerfalse0The ID for the parent of the comment.
postintegerfalse0The ID of the associated post object.
statusstringfalseState of the comment.
metaobjectfalseMeta fields.

Collection GET

ParameterTypeRequiredDefaultDescription
contextstringfalseviewScope under which the request is made; determines fields present in response.
pageintegerfalse1Current page of the collection.
per_pageintegerfalse10Maximum number of items to be returned in result set.
searchstringfalseLimit results to those matching a string.
afterstringfalseLimit response to comments published after a given ISO8601 compliant date.
authorarrayfalseLimit result set to comments assigned to specific user IDs. Requires authorization.
author_excludearrayfalseEnsure result set excludes comments assigned to specific user IDs. Requires authorization.
author_emailstringfalseNoneLimit result set to that from a specific author email. Requires authorization.
beforestringfalseLimit response to comments published before a given ISO8601 compliant date.
excludearrayfalse[]Ensure result set excludes specific IDs.
includearrayfalse[]Limit result set to specific IDs.
offsetintegerfalseOffset the result set by a specific number of items.
orderstringfalsedescOrder sort attribute ascending or descending.
orderbystringfalsedate_gmtSort collection by comment attribute.
parentarrayfalse[]Limit result set to comments of specific parent IDs.
parent_excludearrayfalse[]Ensure result set excludes specific parent IDs.
postarrayfalse[]Limit result set to comments assigned to specific post IDs.
statusstringfalseapproveLimit result set to comments assigned a specific status. Requires authorization.
typestringfalsecommentLimit result set to comments assigned a specific type. Requires authorization.
passwordstringfalseThe password for the post if it is password protected.

Collection POST

ParameterTypeRequiredDefaultDescription
authorintegerfalseThe ID of the user object, if author was a user.
author_emailstringfalseEmail address for the comment author.
author_ipstringfalseIP address for the comment author.
author_namestringfalseDisplay name for the comment author.
author_urlstringfalseURL for the comment author.
author_user_agentstringfalseUser agent for the comment author.
contentobjectfalseThe content for the comment.
datestringfalseThe date the comment was published, in the site’s timezone.
date_gmtstringfalseThe date the comment was published, as GMT.
parentintegerfalse0The ID for the parent of the comment.
postintegerfalse0The ID of the associated post object.
statusstringfalseState of the comment.
metaobjectfalseMeta fields.

Single GET

ParameterTypeRequiredDefaultDescription
idintegerfalseUnique identifier for the comment.
contextstringfalseviewScope under which the request is made; determines fields present in response.
passwordstringfalseThe password for the parent post of the comment (if the post is password protected).

Single POST, PUT, PATCH

ParameterTypeRequiredDefaultDescription
idintegerfalseUnique identifier for the comment.
authorintegerfalseThe ID of the user object, if author was a user.
author_emailstringfalseEmail address for the comment author.
author_ipstringfalseIP address for the comment author.
author_namestringfalseDisplay name for the comment author.
author_urlstringfalseURL for the comment author.
author_user_agentstringfalseUser agent for the comment author.
contentobjectfalseThe content for the comment.
datestringfalseThe date the comment was published, in the site’s timezone.
date_gmtstringfalseThe date the comment was published, as GMT.
parentintegerfalseThe ID for the parent of the comment.
postintegerfalseThe ID of the associated post object.
statusstringfalseState of the comment.
metaobjectfalseMeta fields.

Single DELETE

ParameterTypeRequiredDefaultDescription
idintegerfalseUnique identifier for the comment.
forcebooleanfalseFalseWhether to bypass Trash and force deletion.
passwordstringfalseThe password for the parent post of the comment (if the post is password protected).

Single GET

ParameterTypeRequiredDefaultDescription
idintegerfalseUnique identifier for the comment.
contextstringfalseviewScope under which the request is made; determines fields present in response.
passwordstringfalseThe password for the parent post of the comment (if the post is password protected).

Single POST, PUT, PATCH

ParameterTypeRequiredDefaultDescription
idintegerfalseUnique identifier for the comment.
authorintegerfalseThe ID of the user object, if author was a user.
author_emailstringfalseEmail address for the comment author.
author_ipstringfalseIP address for the comment author.
author_namestringfalseDisplay name for the comment author.
author_urlstringfalseURL for the comment author.
author_user_agentstringfalseUser agent for the comment author.
contentobjectfalseThe content for the comment.
datestringfalseThe date the comment was published, in the site’s timezone.
date_gmtstringfalseThe date the comment was published, as GMT.
parentintegerfalseThe ID for the parent of the comment.
postintegerfalseThe ID of the associated post object.
statusstringfalseState of the comment.
metaobjectfalseMeta fields.

Single DELETE

ParameterTypeRequiredDefaultDescription
idintegerfalseUnique identifier for the comment.
forcebooleanfalseFalseWhether to bypass Trash and force deletion.
passwordstringfalseThe password for the parent post of the comment (if the post is password protected).

Response Schema (Item)

FieldTypeDescription
idintegerUnique identifier for the comment. (read-only)
authorintegerThe ID of the user object, if author was a user.
author_emailstringEmail address for the comment author.
author_ipstringIP address for the comment author.
author_namestringDisplay name for the comment author.
author_urlstringURL for the comment author.
author_user_agentstringUser agent for the comment author.
contentobjectThe content for the comment.
datestringThe date the comment was published, in the site’s timezone.
date_gmtstringThe date the comment was published, as GMT.
linkstringURL to the comment. (read-only)
parentintegerThe ID for the parent of the comment.
postintegerThe ID of the associated post object.
statusstringState of the comment.
typestringType of the comment. (read-only)
author_avatar_urlsobjectAvatar URLs for the comment author. (read-only)
metaobjectMeta fields.

Authentication

  • Read: public for approved comments; unapproved requires moderate_comments.
  • Write: create allowed when site permits; update/delete requires moderate_comments or edit_posts.

Example Requests

bash
curl -X GET "https://wordpress.org/news/wp-json/wp/v2/comments"
bash
curl -X POST "https://wordpress.org/news/wp-json/wp/v2/comments" 
  -H 'Authorization: Basic <app-password>' 
  -H 'Content-Type: application/json' 
  -d '{"title":"Example"}'
bash
curl -X GET "https://wordpress.org/news/wp-json/wp/v2/comments/1"

Example Response (trimmed)

json
{
  "id": 1,
  "_links": {
    "self": [{ "href": "/wp/v2/comments/1" }]
  }
}