# List comments

> The discussion on one plant, explant, contamination log, task, media recipe or SOP, oldest first. Replies carry parent_id. A deleted comment keeps its place, with its text removed, so the replies to it still read in order.

Source: https://docs.xplantpro.com/docs/api/comments/list-comments

`GET https://app.xplantpro.com/api/v1/comments`

- Required scope: `read:comments`
- Credentials: workspace API key (`xpk_`)
- Idempotency-Key: ignored on this endpoint

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `entity_type` | `"plant"` \| `"explant"` \| `"contamination"` \| `"task"` \| `"media_recipe"` \| `"sop"` | Yes | The kind of record whose comments to list. |
| `entity_id` | string (uuid) | Yes | The id of the record whose comments to list. |
| `limit` | integer | No | Page size. Values above 200 are capped at 200. Default `50`. From 1 to 200. |
| `offset` | integer | No | Number of records to skip. Prefer `cursor` where a list offers it: an offset shifts when records are added ahead of it. Default `0`. At least 0. |
| `cursor` | string | No | Continue from the previous page: pass its `meta.next_cursor` unchanged, with the same filters. Treat it as opaque. Not combinable with `offset`. Up to 2048 characters. |

## Example

**curl**

```bash
curl "https://app.xplantpro.com/api/v1/comments?entity_type=explant&entity_id=7c1d9e2a-3b4f-4a5c-8d6e-1f2a3b4c5d6e" \
  -H "Authorization: Bearer $XPLANT_API_KEY"
```

**JavaScript**

```js
import { XPlantClient } from "@shmaplex/xplant-sdk";

const client = new XPlantClient({ apiKey: process.env.XPLANT_API_KEY });

const comments = await client.comments.list({
  entity_type: "explant",
  entity_id: "7c1d9e2a-3b4f-4a5c-8d6e-1f2a3b4c5d6e",
});
```

**Python**

```python
import os
import requests

resp = requests.get(
    "https://app.xplantpro.com/api/v1/comments",
    headers={"Authorization": f"Bearer {os.environ['XPLANT_API_KEY']}"},
    params={
        "entity_type": "explant",
        "entity_id": "7c1d9e2a-3b4f-4a5c-8d6e-1f2a3b4c5d6e",
    },
    timeout=10,
)
body = resp.json()
if not body["ok"]:
    raise RuntimeError(f"{resp.status_code} {body['code']}: {body['error']}")
comments = body["data"]
```

## Response

`200` with `{ "ok": true, "data": … }`. `data` is an array. To get the next page, pass `meta.next_cursor` back as `cursor`; it is `null` on the last page. See [Pagination](https://docs.xplantpro.com/docs/pagination.md).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string (uuid) | Yes | — |
| `entity_type` | `"plant"` \| `"explant"` \| `"contamination"` \| `"task"` \| `"media_recipe"` \| `"sop"` | Yes | The kind of record the comment is on. |
| `entity_id` | string (uuid) | Yes | The record the comment is on. |
| `parent_id` | string \| null (uuid) | Yes | The comment this one replies to. |
| `body` | string | Yes | The comment in Markdown, exactly as written — mentions and record links included as the `@name` and `#type:Label` text the author typed. |
| `status` | string | Yes | `active`; `edited` once changed after posting; or `deleted`, which keeps the comment's place in the thread but not its text. |
| `is_pinned` | boolean | Yes | Pinned to the top of the record's discussion. |
| `author` | object | Yes | — |
| `author.id` | string (uuid) | Yes | User id of the author. |
| `author.name` | string \| null | Yes | The name shown beside the comment in the app, or null when there is none to show. |
| `mentioned_user_ids` | string (uuid)[] | Yes | Workspace members the comment named. Each was notified. |
| `references` | object[] | Yes | Records in the workspace the body links to. A record removed since is left out. |
| `references[].entity_type` | `"plant"` \| `"explant"` \| `"contamination"` \| `"task"` \| `"media_recipe"` \| `"sop"` | Yes | — |
| `references[].entity_id` | string (uuid) | Yes | — |
| `references[].label` | string | Yes | The name the body links from. |
| `created_at` | string \| null | Yes | ISO 8601. |
| `updated_at` | string \| null | Yes | ISO 8601. |
| `edited_at` | string \| null | Yes | When the text was last changed. ISO 8601. |

```json title="Response"
{
  "ok": true,
  "data": [
    {
      "id": "9c4e2a71-3d5b-4f86-b1e0-7a2d6c8f3e45",
      "entity_type": "explant",
      "entity_id": "6d2f9a14-8b3e-4c71-a5d0-1f7e3b8c2a96",
      "parent_id": null,
      "body": "@sam the Alocasia line on shelf 2 is ready to go onto fresh medium. See #task:Subculture-Alocasia-line.",
      "status": "active",
      "is_pinned": false,
      "author": {
        "id": "0d7e4b9a-6f21-4c3e-8a5b-2e9f1c7d4a60",
        "name": "Sam Okafor"
      },
      "mentioned_user_ids": [
        "4a8f1c63-2e7d-4b95-8c10-5d3e9f7a2b68"
      ],
      "references": [
        {
          "entity_type": "task",
          "entity_id": "5b0f6f3e-2c1a-4d8e-9f47-0a6c3e1b7d22",
          "label": "Subculture Alocasia line"
        }
      ],
      "created_at": "2026-09-25T09:15:40.000Z",
      "updated_at": "2026-09-25T09:15:40.000Z",
      "edited_at": null
    }
  ]
}
```

The envelope can also carry `meta`:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `next_cursor` | string \| null | Yes | Pass as `cursor` to fetch the next page. `null` means this is the last page. |

| Response header | Meaning |
| --- | --- |
| `X-Request-Id` | Identifies this request. Include it when you contact support. |

## Errors

| Status | Code | When |
| --- | --- | --- |
| `401` | `UNAUTHORIZED` | The key is missing, malformed or revoked, or its owner is no longer a member of the workspace. |
| `402` | `PAID_PLAN_REQUIRED` | The workspace's plan does not include the API. The full API is included with xPlant+ Teams and Enterprise; on Hobby and Pro Lab, keys can connect devices only. |
| `403` | `FORBIDDEN` | The key lacks a scope this operation requires, or its owner's current role in the workspace cannot use it — a key never does more than its owner can in xPlant. `error` names the scope, and for a role, the role it needs. |
| `403` | `DEVICE_TOKEN_NOT_ACCEPTED` | A device token was sent; this operation needs a workspace API key. |
| `404` | `NOT_FOUND` | `entity_id` names no record of that `entity_type` in the key's workspace. |
| `422` | `VALIDATION_ERROR` | Both `cursor` and `offset` were sent; use one. |
| `422` | `INVALID_CURSOR` | The cursor is malformed, or came from a different list or different filters. Start again without it. |
| `422` | `VALIDATION_ERROR` | `entity_type` or `entity_id` is missing or malformed. |
| `429` | `RATE_LIMIT_EXCEEDED` | Too many requests for this key, device token or workspace. Wait `Retry-After` seconds. |
| `500` | `COMMENT_QUERY_FAILED` | The comments could not be read. Retry later. |

Branch on `code`, never on the `error` text. See [Errors](https://docs.xplantpro.com/docs/errors.md).
