# Add Comment

`POST /pending-approvals/{pendingId}/comments` · Core · Policy & Approvals

Adds a comment to a pending change. A comment is never a decision: it changes no status, counts toward no approval rule, and doesn't extend the expiry.

`visibility` is required and fixed once posted:

- `everyone` reaches everyone who can read the change.
- `approvers_only` reaches only people eligible to decide it, never the person who asked for it or anyone acting for them.

Someone eligible to decide the change may post either kind; the person who asked for it may post `everyone` comments only. `body` is plain text of 1 to 4,000 characters; there's no edit or delete, so a correction is a new comment.

Requires a session: a personal access token alone, or a service, workload or extension token, is refused. Returns `K9O_APPROVAL_COMMENT_NOT_ELIGIBLE` (403) when the caller may not post this comment, and `K9O_APPROVAL_COMMENT_CLOSED` (409) once the change is decided, expired or cancelled.

The audit event `approval.comment_added` carries the comment id, the change id, the visibility and the author's id, never the text.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `pendingId` | path | yes | The pending change's id (`apr_...`). Example: `"apr_3Lq9Wx2Km7Rp5Tz8"`. |
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `body` | string | yes | Plain text, 1 to 4,000 characters. |
| `visibility` | enum ("everyone", "approvers_only") | yes | Required. `everyone`: everyone who can read the case. `approvers_only`: only people eligible to decide it; the person who asked for the change can't post or see these. |

```json
{
  "body": "The refund amount doesn't match the order total. Can you check the line items?",
  "visibility": "everyone"
}
```

## Responses

- **201**: Created

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | A comment on an approval case. |
| `data.id` | string | yes | The comment's id (`acm_...`). |
| `data.caseId` | string | yes | The id of the pending change or gate the comment is on (`apr_...`). |
| `data.authorId` | string | yes | The author's opaque user id. |
| `data.visibility` | enum ("everyone", "approvers_only") | yes | Fixed when posted. `approvers_only` comments are returned only to people eligible to decide the case, never to the person who asked for it. |
| `data.body` | string | yes | Plain text. Render it as text, never as HTML. |
| `data.createdAt` | string (date-time) | yes | When the comment was posted. |
| `meta` | object | yes | Request metadata: cost, timing and correlation ids. |
| `meta.cost` | object | yes | Metered usage for this request; empty when nothing was metered. |
| `meta.timing` | object | yes |  |
| `meta.timing.gatewayMs` | number | yes |  |
| `meta.timing.totalMs` | number | yes |  |
| `meta.context` | object | yes |  |
| `meta.context.requestId` | string | yes |  |
| `meta.context.traceId` | string | yes |  |
| `meta.context.projectId` | string | no |  |
| `meta.warnings` | array of object | no |  |
| `meta.warnings.[]code` | string | yes |  |
| `meta.warnings.[]message` | string | yes |  |


## Errors

| HTTP | Code | When |
|---|---|---|
| 401 | `K9O_SESSION_EXPIRED` | The caller's session token is expired or invalid; re-authenticate to continue. |
| 400 | `K9O_INVALID_FIELD_VALUE` | The body is malformed: `visibility` is missing or not `everyone` or `approvers_only`, `body` is missing, blank, longer than 4,000 characters or holds a NUL character, or an unknown field is present. |
| 403 | `K9O_RBAC_DENY` | A session is required to comment: a personal access token alone is refused with `context.reason` `session_required`, and a service, workload or extension token with `human_only`. |
| 403 | `K9O_APPROVAL_COMMENT_NOT_ELIGIBLE` | The caller may not post this comment: only someone eligible to decide the case may post, and the person who asked for it may post `everyone` comments only. |
| 404 | `K9O_NOT_FOUND` | No pending change with this id exists in this project. |
| 409 | `K9O_APPROVAL_COMMENT_CLOSED` | The case is decided, expired or cancelled, so it takes no new comments; existing comments stay readable. |

## Code samples

### cURL

```bash
curl -X POST 'https://<org>.api-<region>.k9o.io/@storefront/pending-approvals/<pendingId>/comments' \
  -H 'Authorization: Bearer $K9O_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "body": "The refund amount doesn'\''t match the order total. Can you check the line items?",
  "visibility": "everyone"
}'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/pending-approvals/<pendingId>/comments', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.K9O_TOKEN}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
  "body": "The refund amount doesn't match the order total. Can you check the line items?",
  "visibility": "everyone"
}),
});
const { data, meta } = await res.json();
```

### k9o CLI

```bash
k9o approvals comment <id> --body <text> --visibility everyone|approvers_only
```

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.approvals.comments.add('apr_3Lq9Wx2Km7Rp5Tz8', {
  body: 'The refund amount doesn\'t match the order total. Can you check the line items?',
  visibility: 'everyone'
})
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.approvals.comments.add("apr_3Lq9Wx2Km7Rp5Tz8", "The refund amount doesn't match the order total. Can you check the line items?", "everyone")
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.Approvals.Comments.Add(ctx, "apr_3Lq9Wx2Km7Rp5Tz8", k9o.AddApprovalCommentInput{Body: "The refund amount doesn't match the order total. Can you check the line items?", Visibility: "everyone"})
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.approvals().comments().add("apr_3Lq9Wx2Km7Rp5Tz8", AddApprovalCommentInput { body: "The refund amount doesn't match the order total. Can you check the line items?", visibility: "everyone" }).await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.approvals().comments().add("apr_3Lq9Wx2Km7Rp5Tz8", "The refund amount doesn't match the order total. Can you check the line items?", "everyone")
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.Approvals.Comments.AddAsync("apr_3Lq9Wx2Km7Rp5Tz8", "The refund amount doesn't match the order total. Can you check the line items?", "everyone")
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.approvals.comments.add("apr_3Lq9Wx2Km7Rp5Tz8", body: "The refund amount doesn't match the order total. Can you check the line items?", visibility: "everyone")
```

### k9o/sdk

```php
// $k9o = K9oClient::create(['org_slug' => 'playground', 'project_slug' => 'storefront', 'api_key' => 'k9o_…']);
$response = $k9o->approvals->comments->add('apr_3Lq9Wx2Km7Rp5Tz8', 'The refund amount doesn\'t match the order total. Can you check the line items?', 'everyone')
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/add-comment
