# Comment <p>A comment is a reader's response to an article in a blog. Comments appear on the article page in reverse chronological order, typically after the article body. Just as a blog can have any number of articles, an article can have any number of comments.</p> {{ '/api/reference/comment.png' | image }} <p>Article comments are a target for spammers, so Shopify blogs use a spam detection system to identify comments that are likely to be spam. Shop owners can also can mark comments as spam or not spam. Comments that are marked as spam are removed from the Shopify admin and don't appear in the blog.</p> ## Resource Properties ### Comment * article_id: A unique numeric identifier for the article that the comment belongs to. * Type: x-string * Example: 134645308 * author: The name of the author of the comment. * Type: x-string * Example: "Soleone" * blog_id: A unique numeric identifier for the blog containing the article that the comment belongs to. * Type: x-string * Example: 241253187 * body: The basic <a href="https://en.wikipedia.org/wiki/Textile_(markup_language)">Textile markup</a> of a comment. * Type: x-string * Example: "This is a _great_ article." * body_html: The text of the comment, complete with HTML markup. * Type: x-string * Example: "<p>This is a <em>great</em> article.</p>" * created_at: The date and time (<a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> format) when the comment was created. * Type: x-string * Example: "2012-08-24T14:01:46-04:00" * email: The email address of the author of the comment. * Type: x-string * Example: "soleone@example.net" * id: A unique numeric identifier for the comment. * Type: x-string * Example: 653537639 * ip: The IP address from which the comment was posted. * Type: x-string * Example: "127.0.0.1" * published_at: The date and time (<a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> format) when the comment was published. * Type: x-string * Example: "2012-08-24T14:02:00-04:00" * status: <p>The status of the comment. Valid values:</p> <ul> <li><strong>pending</strong>: The comment has been created but is awaiting spam detection. Depending on the result of the spam detection and the shop owner's comment preferences, this property will be transitioned to either <code>spam</code>, <code>unapproved</code>, or <code>approved</code>.</li> <li><strong>unapproved (default)</strong>: The comment is awaiting approval by the shop owner. It's not visible to the readers of the blog.</li> <li><strong>published</strong>: The comment has been approved (if the blog requires comments to be approved) and is visible to readers of the blog.</li> <li><strong>spam</strong>: The comment has been marked as spam and removed from the Shopify admin. It's not visible to readers of the blog.</li> <li><strong>removed</strong>: The comment has been removed by the shop owner. It's not visible to readers of the blog.</li> </ul> * Type: x-string * Example: "unapproved" * updated_at: The date and time (<a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> format) when the comment was last modified. When the comment is created, this matches the value of <code>created_at</code>. If the blog requires comments to be approved, then this value is updated to the date and time when the comment is approved. * Type: x-string * Example: "2012-08-24T14:02:00-04:00" * user_agent: The user agent string provided by the software used to create the comment (usually a browser). * Type: x-string * Example: "Mozilla/5.0" ## Retrieves a list of comments Retrieves a list of comments. <strong>Note:</strong> This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to <a href='/api/usage/pagination-rest'>Make paginated requests to the REST Admin API</a>. ### Endpoint /admin/api/#{api_version}/comments.json?since_id=118373535 (GET) ### Parameters * api_version (required): * created_at_max: Show comments created before date (format: 2014-04-25T16:15:47-04:00). * created_at_min: Show comments created after date (format: 2014-04-25T16:15:47-04:00). * fields: Show only certain fields, specified by a comma-separated list of field names. * limit: The maximum number of results to retrieve. * published_at_max: Show comments published before date (format: 2014-04-25T16:15:47-04:00). * published_at_min: Show comments published after date (format: 2014-04-25T16:15:47-04:00). * published_status: Filter results by their published status. * since_id: Restrict results to after the specified ID. * status: Filter results by their status. * updated_at_max: Show comments last updated before date (format: 2014-04-25T16:15:47-04:00). * updated_at_min: Show comments last updated after date (format: 2014-04-25T16:15:47-04:00). ### Responses #### 200 Retrieves a list of comments Examples: ##### Retrieve all comments for this shop after the specified ID Request: ``` GET /admin/api/unstable/comments.json ``` Response: ``` HTTP/1.1 200 OK {"comments":[{"id":653537639,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","status":"unapproved","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1","published_at":null}]} ``` ##### Retrieve all the comments for a certain article of a blog Request: ``` GET /admin/api/unstable/comments.json ``` Response: ``` HTTP/1.1 200 OK {"comments":[{"id":653537639,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","status":"unapproved","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1","published_at":null},{"id":118373535,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","status":"published","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1","published_at":null}]} ``` ##### Retrieve all the comments for all the articles of a blog Request: ``` GET /admin/api/unstable/comments.json ``` Response: ``` HTTP/1.1 200 OK {"comments":[{"id":653537639,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","status":"unapproved","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1","published_at":null},{"id":118373535,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","status":"published","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1","published_at":null}]} ``` ##### Retrieve all the comments for this shop Request: ``` GET /admin/api/unstable/comments.json ``` Response: ``` HTTP/1.1 200 OK {"comments":[{"id":653537639,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","status":"unapproved","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1","published_at":null},{"id":118373535,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","status":"published","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1","published_at":null}]} ``` ## Retrieves a count of comments Retrieves a count of comments ### Endpoint /admin/api/#{api_version}/comments/count.json?article_id=134645308&blog_id=241253187 (GET) ### Parameters * api_version (required): * created_at_max: Count comments created before date (format: 2014-04-25T16:15:47-04:00). * created_at_min: Count comments created after date (format: 2014-04-25T16:15:47-04:00). * published_at_max: Count comments published before date (format: 2014-04-25T16:15:47-04:00). * published_at_min: Count comments published after date (format: 2014-04-25T16:15:47-04:00). * published_status: Retrieve a count of comments with a given published status. * status: Retrieve a count of comments with a given status. * updated_at_max: Count comments last updated before date (format: 2014-04-25T16:15:47-04:00). * updated_at_min: Count comments last updated after date (format: 2014-04-25T16:15:47-04:00). ### Responses #### 200 Retrieves a count of comments Examples: ##### Count all comments for a certain article of a blog Request: ``` GET /admin/api/unstable/comments/count.json ``` Response: ``` HTTP/1.1 200 OK {"count":2} ``` ##### Count all the comments for all the articles of a blog Request: ``` GET /admin/api/unstable/comments/count.json ``` Response: ``` HTTP/1.1 200 OK {"count":2} ``` ##### Count all the comments for this shop Request: ``` GET /admin/api/unstable/comments/count.json ``` Response: ``` HTTP/1.1 200 OK {"count":2} ``` ## Retrieves a single comment by its ID Retrieves a single comment by its ID ### Endpoint /admin/api/#{api_version}/comments/{comment_id}.json (GET) ### Parameters * api_version (required): * comment_id (required): * fields: Show only certain fields, specified by a comma-separated list of field names. ### Responses #### 200 Retrieves a single comment by its ID Examples: ##### Retrieve a single comment Request: ``` GET /admin/api/unstable/comments/118373535.json ``` Response: ``` HTTP/1.1 200 OK {"comment":{"id":118373535,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","status":"published","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1","published_at":null}} ``` ## Updates a comment of an article Updates a comment of an article ### Endpoint /admin/api/#{api_version}/comments/{comment_id}.json (PUT) ### Parameters * api_version (required): * comment_id (required): ### Responses #### 200 Updates a comment of an article Examples: ##### Update the body of an existing comment Request: ``` PUT /admin/api/unstable/comments/118373535.json {"comment":{"id":118373535,"body":"You can even update through a web service.","author":"Your new name","email":"your@updated-email.com","published_at":"2025-01-02T16:22:10.772Z"}} ``` Response: ``` HTTP/1.1 200 OK {"comment":{"author":"Your new name","body":"You can even update through a web service.","email":"your@updated-email.com","published_at":"2025-01-02T11:22:10-05:00","id":118373535,"body_html":"<p>You can even update through a web service.</p>","status":"published","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:22:11-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"}} ``` ## Creates a comment for an article Creates a comment for an article ### Endpoint /admin/api/#{api_version}/comments.json (POST) ### Parameters * api_version (required): ### Responses #### 201 Creates a comment for an article Examples: ##### Create a comment for an article of a blog using basic Textile markup Request: ``` POST /admin/api/unstable/comments.json {"comment":{"body":"I like comments\nAnd I like posting them *RESTfully*.","author":"Your name","email":"your@email.com","ip":"107.20.160.121","blog_id":241253187,"article_id":134645308}} ``` Response: ``` HTTP/1.1 201 Created {"comment":{"id":757536351,"body":"I like comments\nAnd I like posting them *RESTfully*.","body_html":"<p>I like comments<br>\nAnd I like posting them <strong>RESTfully</strong>.</p>","author":"Your name","email":"your@email.com","status":"pending","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:22:08-05:00","updated_at":"2025-01-02T11:22:08-05:00","ip":"107.20.160.121","user_agent":null,"published_at":null}} ``` #### 422 Creates a comment for an article Examples: ##### Creating a comment without a body, author, and email fails and returns an error Request: ``` POST /admin/api/unstable/comments.json {"comment":{"article_id":134645308}} ``` Response: ``` HTTP/1.1 422 Unprocessable Entity {"errors":{"author":["can't be blank"],"body":["can't be blank"],"email":["must be formatted as an email"]}} ``` ## Marks a comment as spam Marks a comment as spam ### Endpoint /admin/api/#{api_version}/comments/{comment_id}/spam.json (POST) ### Parameters * api_version (required): * comment_id (required): ### Responses #### 200 Marks a comment as spam Examples: ##### Mark a comment as spam Request: ``` POST /admin/api/unstable/comments/653537639/spam.json {} ``` Response: ``` HTTP/1.1 200 OK {"published_at":null,"status":"spam","id":653537639,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:22:08-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"} ``` ## Marks a comment as not spam Marks a comment as not spam ### Endpoint /admin/api/#{api_version}/comments/{comment_id}/not_spam.json (POST) ### Parameters * api_version (required): * comment_id (required): ### Responses #### 200 Marks a comment as not spam Examples: ##### Mark a comment as not spam, restoring it to an unapproved or published state Request: ``` POST /admin/api/unstable/comments/653537639/not_spam.json {} ``` Response: ``` HTTP/1.1 200 OK {"published_at":"2025-01-02T11:22:07-05:00","status":"published","id":653537639,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:22:07-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"} ``` ## Approves a comment Approves a comment ### Endpoint /admin/api/#{api_version}/comments/{comment_id}/approve.json (POST) ### Parameters * api_version (required): * comment_id (required): ### Responses #### 200 Approves a comment Examples: ##### Approve a comment and publish it to the blog Request: ``` POST /admin/api/unstable/comments/653537639/approve.json {} ``` Response: ``` HTTP/1.1 200 OK {"published_at":"2025-01-02T11:22:14-05:00","status":"published","id":653537639,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:22:14-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"} ``` ## Removes a comment Removes a comment ### Endpoint /admin/api/#{api_version}/comments/{comment_id}/remove.json (POST) ### Parameters * api_version (required): * comment_id (required): ### Responses #### 200 Removes a comment Examples: ##### Remove a comment Request: ``` POST /admin/api/unstable/comments/653537639/remove.json {} ``` Response: ``` HTTP/1.1 200 OK {"published_at":null,"status":"removed","id":653537639,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:22:18-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"} ``` ## Restores a previously removed comment Restores a previously removed comment ### Endpoint /admin/api/#{api_version}/comments/{comment_id}/restore.json (POST) ### Parameters * api_version (required): * comment_id (required): ### Responses #### 200 Restores a previously removed comment Examples: ##### Restore a removed comment Request: ``` POST /admin/api/unstable/comments/653537639/restore.json {} ``` Response: ``` HTTP/1.1 200 OK {"published_at":"2025-01-02T11:22:20-05:00","status":"published","id":653537639,"body":"Hi author, I really _like_ what you're doing there.","body_html":"<p>Hi author, I really <em>like</em> what you're doing there.</p>","author":"Soleone","email":"soleone@example.net","article_id":134645308,"blog_id":241253187,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:22:20-05:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"} ```