Post Comments

JSON Format

Comments made on posts have the following keys:

Name Type Read-only Mandatory Comment
id integer yes no Automatically assigned when the comment is created
url string yes no The API url of the comment
html_url string yes no The community url of the comment
body string no yes The comment made by the author
author_id integer yes* no The id of the author of the comment. *Writable on create by Help Center managers -- see Create Comment
post_id integer yes no The id of the post on which the comment was made
official boolean no no Whether the comment is marked as official
vote_sum integer yes no The sum of upvotes (+1) and downvotes (-1), which may be positive or negative
vote_count integer yes no The total number of upvotes and downvotes
created_at timestamp yes* no When the comment was created. *Writable on create by Help Center managers -- see Create Comment
updated_at timestamp yes no When the comment was last updated
Example
{
  "id": 35467,
  "body": "My printer is on fire!",
  "author_id": 89567,
  "vote_sum": 10,
  "vote_count": 15,
  "official": false,
  ...
}

List Comments

  • GET /api/v2/community/posts/{post_id}/comments.json
  • GET /api/v2/community/users/{id}/comments.json

Lists all comments on a specific post or all the comments created by a specific user. When listing comments by specific user, the comments of the user making the request can be listed by specifying me as the id.

Allowed for
  • Agents
  • End users
Sideloads

You can sideload related records with the include query string parameter. The following sideloads are supported:

Name Will sideload
users authors
posts posts

See Sideloading related records in the Develop Help Center.

Using curl
curl https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments.json \
  -v -u {email_address}:{password}
curl https://{subdomain}.zendesk.com/api/v2/community/users/{id}/comments.json \
  -v -u {email_address}:{password}
Example Response
Status: 200 OK

{
  "comments": [
    {
      "id":        35467,
      "body":      "My printer is on fire!",
      "author_id": 89567,
      ...
    },
    {
      "id":        36221,
      "body":      "My printer is on fire too!",
      "author_id": 89589,
      ...
    },
    ...
  ]
}

Show Comment

GET /api/v2/community/posts/{post_id}/comments/{id}.json

Shows information about the specified comment.

Allowed for
  • Agents
  • End users
Sideloads

The following sideloads are supported:

Name Will sideload
users The comment's author
posts The comment's post
Using curl
curl https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments/{id}.json \
  -v -u {email_address}:{password}
Example Response
Status: 200 OK

{
  "comment": {
    "id":        35467,
    "body":      "My printer is on fire",
    "author_id": 89567,
    ...
  }
}

Create Comment

POST /api/v2/community/posts/{post_id}/comments.json

Adds a comment to the specified post.

Allowed for
  • Agents
  • End users

Agents with the Help Center manager role can optionally supply an author_id as part of the comment object. If it is provided, the comment's author will be set to the value of the author_id key.

Supplying a notify_subscribers property with a value of false will prevent subscribers to the comment's post from receiving a comment creation email notification. This can be helpful when creating many comments at a time. Specify the property in the root of the JSON object, not in the "comment" object.

Using curl
curl https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments.json \
  -d '{"comment": {"body": "I love my new non-flammable printer!"}, "notify_subscribers": false}' \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"

Setting the comment's author:

curl https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments.json \
  -d '{"comment": {"body": "I love my new non-flammable printer!", "author_id": 10056}}' \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"
Example Response
Status: 201 Created

{
  "comment": {
    "id": 35467,
    "body": "I love my new non-flammable printer!",
    "author_id": 89567
    ...
  }
}

Update Comment

PUT /api/v2/community/posts/{post_id}/comments/{id}.json

Updates the specified comment.

Allowed for
  • Agents
  • The end user who created the comment
Using curl
curl https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments/{id}.json \
  -d '{"comment": {"body": "The new, non-flammable printer is on fire too!"}}' \
  -v -u {email_address}:{password} -X PUT -H "Content-Type: application/json"
Example Response
Status: 200 OK

{
  "comment": {
    "id": 35467,
    "body": "The new, non-flammable printer is on fire too!",
    "author_id": 89567
    ...
  }
}

Delete Comment

DELETE /api/v2/community/posts/{post_id}/comments/{id}.json

Deletes the specified comment.

Allowed for
  • Agents
  • The end user who created the comment
Using curl
curl https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments/{id}.json \
  -v -u {email_address}:{password} -X DELETE
Example Response
Status: 204 No Content