Search Documentation

Search for a documentation page...

Post Comments API

REST API endpoints for moderating blog comments and accepting visitor submissions.

Blog comments have two sides. Visitors submit comments via POST /api/v1/posts/{idOrSlug}/comments — these arrive unapproved and stay hidden until a moderator approves them. The store-scoped moderation endpoints under /api/v1/post-comments let you list every comment (including pending ones), approve or reject them, and delete spam.

List Comments (Moderation)

GET /api/v1/post-comments

Returns blog comments across all posts for moderation, including those still pending approval. Use this to build a moderation queue. To submit a comment as a visitor, use POST /api/v1/posts/{idOrSlug}/comments instead.

Query Parameters

ParameterTypeDefaultDescription
limitnumber20Comments per page (1-100)
offsetnumber0Comments to skip
querystringSearch term for content, author, or email
approvedbooleanFilter by approval status (omit for all, including pending)
curl \
-H "Authorization: Bearer your_api_key" \
"https://your-store.yns.store/api/v1/post-comments?approved=false&limit=20"

Response (200)

{
"data": [
{
"id": "0191abc0-1234-7def-8000-000000000001",
"postId": "0191abc0-0000-7000-8000-000000000100",
"author": "Jane Doe",
"email": "jane@example.com",
"content": "Great write-up, thanks for sharing!",
"approved": false,
"userId": null,
"post": {
"id": "0191abc0-0000-7000-8000-000000000100",
"title": "Spring Collection Preview",
"slug": "spring-collection-preview"
},
"createdAt": "2024-06-15T10:30:00.000Z",
"updatedAt": "2024-06-15T10:30:00.000Z"
}
],
"meta": {
"count": 1,
"offset": 0,
"limit": 20
}
}

Get Comment

GET /api/v1/post-comments/{id}

Returns a single blog comment by UUID.

Response (200)

{
"id": "0191abc0-1234-7def-8000-000000000001",
"postId": "0191abc0-0000-7000-8000-000000000100",
"author": "Jane Doe",
"email": "jane@example.com",
"content": "Great write-up, thanks for sharing!",
"approved": false,
"userId": null,
"post": {
"id": "0191abc0-0000-7000-8000-000000000100",
"title": "Spring Collection Preview",
"slug": "spring-collection-preview"
},
"createdAt": "2024-06-15T10:30:00.000Z",
"updatedAt": "2024-06-15T10:30:00.000Z"
}

Not Found (404)

{
"error": "Comment not found"
}

Approve or Reject Comment

PATCH /api/v1/post-comments/{id}

Sets the comment's approved flag. true publishes it on the storefront; false unpublishes/rejects it.

Request Body

FieldTypeRequiredDescription
approvedbooleanYestrue to publish, false to unpublish/reject
curl -X PATCH \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{"approved": true}' \
https://your-store.yns.store/api/v1/post-comments/0191abc0-1234-7def-8000-000000000001

Response (200)

Returns the updated comment with the new approved value.

{
"id": "0191abc0-1234-7def-8000-000000000001",
"postId": "0191abc0-0000-7000-8000-000000000100",
"author": "Jane Doe",
"email": "jane@example.com",
"content": "Great write-up, thanks for sharing!",
"approved": true,
"userId": null,
"post": {
"id": "0191abc0-0000-7000-8000-000000000100",
"title": "Spring Collection Preview",
"slug": "spring-collection-preview"
},
"createdAt": "2024-06-15T10:30:00.000Z",
"updatedAt": "2024-06-15T11:05:00.000Z"
}

Delete Comment

DELETE /api/v1/post-comments/{id}

Hard-deletes the comment by UUID.

curl -X DELETE \
-H "Authorization: Bearer your_api_key" \
https://your-store.yns.store/api/v1/post-comments/0191abc0-1234-7def-8000-000000000001

Response (200)

{
"ok": true,
"deleted": 1
}

List Comments on a Post

GET /api/v1/posts/{idOrSlug}/comments

Returns approved comments for a single post, resolved by UUID or slug, newest first. This is the visitor-facing list shown on the storefront — pending comments are excluded.

Query Parameters

ParameterTypeDefaultDescription
limitnumber20Comments per page (1-100)
offsetnumber0Comments to skip
curl \
-H "Authorization: Bearer your_api_key" \
https://your-store.yns.store/api/v1/posts/spring-collection-preview/comments

Response (200)

{
"data": [
{
"id": "0191abc0-1234-7def-8000-000000000001",
"author": "Jane Doe",
"content": "Great write-up, thanks for sharing!",
"createdAt": "2024-06-15T10:30:00.000Z"
}
],
"meta": {
"count": 1,
"offset": 0,
"limit": 20
}
}

Add a Comment to a Post

POST /api/v1/posts/{idOrSlug}/comments

Creates a comment on the given post (resolved by UUID or slug). New comments are created unapproved (approved: false) and stay hidden until a moderator approves them via PATCH /api/v1/post-comments/{id}.

Request Body

FieldTypeRequiredDescription
authorstringYesCommenter display name (1-100 characters)
emailstringYesCommenter email address (valid email)
contentstringYesComment text (1-5000 characters)
curl -X POST \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{"author": "Jane Doe", "email": "jane@example.com", "content": "Great write-up, thanks for sharing!"}' \
https://your-store.yns.store/api/v1/posts/spring-collection-preview/comments

Response (201)

{
"id": "0191abc0-1234-7def-8000-000000000001",
"author": "Jane Doe",
"content": "Great write-up, thanks for sharing!",
"createdAt": "2024-06-15T10:30:00.000Z"
}