Get Comments

Returns a list of comments.

Query Parameters

fields
array

Control what fields are being returned in the object.

limit
integer

A limit on the number of objects that are returned.

meta
string

What metadata to return in the response.

offset
integer

How many items to skip when fetching data.

sort
array

How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ? to sort randomly.

filter

Select items in collection by given conditions.

search
string

Filter by items that contain the given search query in one of their fields.

Response

Successful request

data
array
meta
object
GET /comments
Response Example
{
  "data": [
    {
      "collection": "articles",
      "id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
      "item": 15,
      "comment": "This is a comment on an article",
      "date_created": "2023-01-15T09:14:52Z",
      "date_updated": "2023-01-15T09:00:00Z",
      "user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
      "user_updated": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af"
    }
  ],
  "meta": {}
}

Create Multiple comments

Create multiple new comments. This action is only available to authenticated users.

Query Parameters

fields
array

Control what fields are being returned in the object.

limit
integer

A limit on the number of objects that are returned.

meta
string

What metadata to return in the response.

offset
integer

How many items to skip when fetching data.

sort
array

How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ? to sort randomly.

filter

Select items in collection by given conditions.

search
string

Filter by items that contain the given search query in one of their fields.

Request Body

data
array

Response

Successful request

data
array
meta
object
POST /comments
Response Example
{
  "data": [
    {
      "collection": "articles",
      "id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
      "item": 15,
      "comment": "This is a comment on an article",
      "date_created": "2023-01-15T09:14:52Z",
      "date_updated": "2023-01-15T09:00:00Z",
      "user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
      "user_updated": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af"
    }
  ],
  "meta": {}
}

Delete Multiple Comments

Delete multiple existing comments. This action is only available to authenticated users.

Request Body

An array of comment primary keys.

[array]
array
DELETE /comments

Update Multiple comments

Update multiple existing comments. This action is only available to authenticated users.

Query Parameters

fields
array

Control what fields are being returned in the object.

limit
integer

A limit on the number of objects that are returned.

meta
string

What metadata to return in the response.

offset
integer

How many items to skip when fetching data.

sort
array

How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ? to sort randomly.

filter

Select items in collection by given conditions.

search
string

Filter by items that contain the given search query in one of their fields.

Request Body

data
object
keys
array

Response

Successful request

data
array
meta
object
PATCH /comments
Response Example
{
  "data": [
    {
      "collection": "articles",
      "id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
      "item": 15,
      "comment": "This is a comment on an article",
      "date_created": "2023-01-15T09:14:52Z",
      "date_updated": "2023-01-15T09:00:00Z",
      "user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
      "user_updated": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af"
    }
  ],
  "meta": {}
}

Create a Comment

Creates a new comment.

Query Parameters

meta
string

What metadata to return in the response.

Request Body

collection
string
item
integer
comment
string

Response

Successful request

data
object
POST /comments‎
Response Example
{
  "data": {
    "id": 2,
    "action": "update",
    "timestamp": "2019-12-05T22:52:09Z",
    "ip": "127.0.0.1",
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/78.0.3904.108 Safari/537.36",
    "item": "328",
    "comment": null,
    "origin": "https://directus.io",
    "revisions": []
  }
}

Get Comment by ID

Returns a single comment by primary key.

Query Parameters

id
integer

Identifier for the object.

fields
array

Control what fields are being returned in the object.

meta
string

What metadata to return in the response.

Response

Successful request

data
object
GET /comments/{id}
Response Example
{
  "data": {
    "collection": "articles",
    "id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
    "item": 15,
    "comment": "This is a comment on an article",
    "date_created": "2023-01-15T09:14:52Z",
    "date_updated": "2023-01-15T09:00:00Z",
    "user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
    "user_updated": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af"
  }
}

Delete a Comment

Delete an existing comment. This action is only available to authenticated users.

Query Parameters

id
integer

Identifier for the object.

DELETE /comments/{id}

Update a Comment

Update an existing comment. This action is only available to authenticated users.

Query Parameters

id
integer

Identifier for the object.

meta
string

What metadata to return in the response.

Request Body

[object]
object

Response

Successful request

data
object
PATCH /comments/{id}
Response Example
{
  "data": {
    "id": 2,
    "action": "update",
    "timestamp": "2019-12-05T22:52:09Z",
    "ip": "127.0.0.1",
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/78.0.3904.108 Safari/537.36",
    "item": "328",
    "comment": null,
    "origin": "https://directus.io",
    "revisions": []
  }
}