Comments Resource Documentation

Read operations merge shared global comments with your session's overlay (newly created comments appear at the top, updates apply in-place, deletes are filtered). Each comment belongs to a post (`post_id` foreign key). Mutations are session-scoped and capped at 30 created records.

GET /comments

Retrieve a paginated list of comments. Results merge shared global comments with session sandbox overlays (newly created comments appear at the top).

Request Parameters
Name Type Location Description
page integer query Page number (1-indexed, default 1).
limit integer query Number of records per page (default 10, max 30).
curl -X GET 'http://localhost:3000/comments' \
  -H 'Content-Type: application/json' \
  -b "pg_identity=your_cookie_uuid"

Response Schema Example

{
  "data": [
    {
      "id": "local-c3d4e5f6-7890-abcd-ef12-345678901234",
      "post_id": 1,
      "name": "id labore ex et quam laborum",
      "_sandbox": "created"
    },
    {
      "id": 1,
      "post_id": 1,
      "name": "id labore ex et quam laborum",
      "email": "Eliseo@gardner.biz",
      "body": "laudantium enim quasi est quidem magnam voluptatem aut eveniet quas aliquid sint expedita consequuntur alias ea quam expedita possimus"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 301,
    "totalPages": 31,
    "hasNextPage": true,
    "hasPrevPage": false
  }
}
⚡ Try it out — Test endpoint live Run fetch
GET /comments/:id

Retrieve a single comment by ID. Supports plain integer IDs for global records (e.g. 1) and string IDs formatted as local-<uuid> for session sandbox records.

Request Parameters
Name Type Location Description
id string | integer path Comment ID (e.g. 1 for global comment or local-<uuid> for sandbox comment).
curl -X GET 'http://localhost:3000/comments/:id' \
  -H 'Content-Type: application/json' \
  -b "pg_identity=your_cookie_uuid"

Response Schema Example

{
  "id": 1,
  "post_id": 1,
  "name": "id labore ex et quam laborum",
  "email": "Eliseo@gardner.biz",
  "body": "laudantium enim quasi est quidem magnam voluptatem aut eveniet quas aliquid sint expedita consequuntur alias ea quam expedita possimus"
}
⚡ Try it out — Test endpoint live Run fetch
POST /comments

Create a new session sandbox comment record. Returns a local-<uuid> formatted ID with _sandbox: 'created'. Each session identity is capped at 30 created records.

Request Parameters
Name Type Location Description
post_id integer body Target post ID.
name string body Comment title or reviewer name.
email string body Commenter email address.
body string body Comment text content.
curl -X POST 'http://localhost:3000/comments' \
  -H 'Content-Type: application/json' \
  -b "pg_identity=your_cookie_uuid" \
  -d '{
  "post_id": 1,
  "name": "id labore ex et quam laborum",
  "email": "Eliseo@gardner.biz",
  "body": "laudantium enim quasi est quidem magnam voluptatem aut eveniet quas aliquid sint expedita consequuntur alias ea quam expedita possimus"
}'

Request Payload Example

{
  "post_id": 1,
  "name": "id labore ex et quam laborum",
  "email": "Eliseo@gardner.biz",
  "body": "laudantium enim quasi est quidem magnam voluptatem aut eveniet quas aliquid sint expedita consequuntur alias ea quam expedita possimus"
}

Response Schema Example

{
  "id": "local-c3d4e5f6-7890-abcd-ef12-345678901234",
  "post_id": 1,
  "name": "id labore ex et quam laborum",
  "email": "Eliseo@gardner.biz",
  "body": "laudantium enim quasi est quidem magnam voluptatem aut eveniet quas aliquid sint expedita consequuntur alias ea quam expedita possimus",
  "_sandbox": "created"
}
⚡ Try it out — Test endpoint live Run fetch
PUT /comments/:id

Replace an existing comment record in the session overlay. Global records remain untouched for other visitors and preserve original list position.

Request Parameters
Name Type Location Description
id string | integer path Comment ID to update (e.g. 1 or local-<uuid>).
curl -X PUT 'http://localhost:3000/comments/:id' \
  -H 'Content-Type: application/json' \
  -b "pg_identity=your_cookie_uuid" \
  -d '{
  "post_id": 1,
  "name": "id labore ex et quam laborum (Updated)",
  "email": "Eliseo@gardner.biz",
  "body": "laudantium enim quasi est quidem magnam voluptatem aut eveniet quas aliquid sint expedita consequuntur alias ea quam expedita possimus"
}'

Request Payload Example

{
  "post_id": 1,
  "name": "id labore ex et quam laborum (Updated)",
  "email": "Eliseo@gardner.biz",
  "body": "laudantium enim quasi est quidem magnam voluptatem aut eveniet quas aliquid sint expedita consequuntur alias ea quam expedita possimus"
}

Response Schema Example

{
  "id": 1,
  "post_id": 1,
  "name": "id labore ex et quam laborum (Updated)",
  "email": "Eliseo@gardner.biz",
  "body": "laudantium enim quasi est quidem magnam voluptatem aut eveniet quas aliquid sint expedita consequuntur alias ea quam expedita possimus",
  "_sandbox": "updated"
}
⚡ Try it out — Test endpoint live Run fetch
PATCH /comments/:id

Partially update specific fields of a comment record in the session overlay.

Request Parameters
Name Type Location Description
id string | integer path Comment ID to patch (e.g. 1 or local-<uuid>).
curl -X PATCH 'http://localhost:3000/comments/:id' \
  -H 'Content-Type: application/json' \
  -b "pg_identity=your_cookie_uuid" \
  -d '{
  "name": "id labore ex et quam laborum (Updated)"
}'

Request Payload Example

{
  "name": "id labore ex et quam laborum (Updated)"
}

Response Schema Example

{
  "id": 1,
  "post_id": 1,
  "name": "id labore ex et quam laborum (Updated)",
  "email": "Eliseo@gardner.biz",
  "body": "laudantium enim quasi est quidem magnam voluptatem aut eveniet quas aliquid sint expedita consequuntur alias ea quam expedita possimus",
  "_sandbox": "updated"
}
⚡ Try it out — Test endpoint live Run fetch
DELETE /comments/:id

Remove a comment record from the requesting session view. The underlying global record is unaffected for other visitors.

Request Parameters
Name Type Location Description
id string | integer path Comment ID to delete (e.g. 1 or local-<uuid>).
curl -X DELETE 'http://localhost:3000/comments/:id' \
  -H 'Content-Type: application/json' \
  -b "pg_identity=your_cookie_uuid"

Response Schema Example

204 No Content
⚡ Try it out — Test endpoint live Run fetch