# write_document

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

Write a ticket's document whole, as its next revision, such as the first draft of its Scope or Plan. Pass the revision you read. For a change to part of a document, use edit_document. Up to 200,000 characters. 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.
- `body` (string, required): The whole document in Markdown.
- `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": "write_document",
    "arguments": {
      "ticket": "WEB-31",
      "document": "Plan",
      "body": "## Overview\nReaders find any docs page from the header.",
      "baseRevision": 0
    }
  }
}
```

## 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:write-document \
  -H "Authorization: Bearer $CLANKER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "ticket": "WEB-31",
    "document": "Plan",
    "body": "## Overview\nReaders find any docs page from the header.",
    "baseRevision": 0
  }'
```
