# edit_document

`tools/call` · `POST /clanker/v1/tickets:edit-document`

Change passages of a ticket's document as its next revision, all or none. Each old passage must appear exactly once in the revision you read; include more of the text around it when it does not. Up to 50 passages. Returns the document. Needs write access.

- Area: Planning
- Needs the write grant. Idempotent.

## Inputs

- `ticket` (string, required): A ticket ID, such as WEB-31.
- `document` (string, required): A document's name or slug from get_ticket, such as Plan or build-record.
- `edits` (array of objects, required): The passages to change. At least 1 item.
  - `old` (string, required): A passage that appears exactly once in the document.
  - `new` (string, required): What replaces it.
- `baseRevision` (integer, required): The revision you read with get_document: 0 for an unwritten document. A change from an older revision is refused; read it again and redo your change. From 0 to 9,007,199,254,740,991.

## Request

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "edit_document",
    "arguments": {
      "ticket": "WEB-31",
      "document": "build-record",
      "edits": [
        {
          "old": "## Decisions\n",
          "new": "## Decisions\n- Index at build time, not on request.\n"
        }
      ],
      "baseRevision": 4
    }
  }
}
```

## HTTP request

The same call over the clanker HTTP API, with a clanker OAuth access token:

```bash
curl -X POST https://api.clankership.com/clanker/v1/tickets:edit-document \
  -H "Authorization: Bearer $CLANKER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "ticket": "WEB-31",
    "document": "build-record",
    "edits": [
      {
        "old": "## Decisions\n",
        "new": "## Decisions\n- Index at build time, not on request.\n"
      }
    ],
    "baseRevision": 4
  }'
```
