> ## Documentation Index
> Fetch the complete documentation index at: https://docs.avazal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Documents and canvases

> Read, create, edit, restore and publish Avazal documents and Slack canvases, and share public links.

Documents are Avazal's own pages, kept in a folder tree. Slack canvases are documents too: reading one brings it into your documents. `source` says which (`avazal` or `slack`). What a run saves with `documents.save` (a page, screenshots, a report or a file) is a document too, with an `aart_…` id and its `run`. Reading needs `documents:read`; creating, editing and publishing need `documents:write`.

## Read documents

```bash theme={null}
avazal documents.list
avazal documents.get --id doc_…
```

`documents.list` returns documents, folders and canvases, most recently updated first. Narrow it with `source`, `parentId` (a folder, or `null` for the top level), `query`, `kind`, `run` for what one run saved, and for canvases `conversation`. Add `account`, a Slack workspace, to also list canvases nobody has opened in Avazal yet.

`documents.get` returns the `markdown`, the `revisionId` you need to edit it, and a `version`. Add `context: true` for the folders the document sits in and the Slack List tasks it is attached to, read with [`tasks.get`](https://docs.avazal.com/guides/tasks). `revisionId` reads an earlier revision.

An unopened canvas is `chcv_…/<file id>`; once Avazal has it, its id is a `doc_…` id. Both work wherever an operation takes a document. A Slack canvas link works too: [`search.resolve`](https://docs.avazal.com/concepts/links) returns its id.

Over MCP, documents are also resources: `resources/list` returns them, and `avazal://documents/{id}` reads one.

## Create

```bash theme={null}
curl -X POST https://api.avazal.com/v1/documents.create \
  -H "Authorization: Bearer $AVAZAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"parentId": null, "name": "Launch notes", "kind": "file", "markdown": "# Launch notes\n\n- Ship on Thursday"}'
```

Set `parentId` to a folder's id to create inside it, or `null` for the top level. Use `kind: "folder"` for a folder. Pass `conversation` instead to create a Slack canvas in a channel or DM; it is added as a tab there and posted to it, which is [outward](https://docs.avazal.com/authentication.md#risk).

## Edit

`documents.update` replaces the content. Pass the `revisionId` you read as `expectedRevisionId`:

```bash theme={null}
avazal documents.update '{"id": "doc_…", "expectedRevisionId": "drev_…", "markdown": "# Launch notes\n\n- Ship on Friday"}'
```

If someone changed the document since you read it, the update fails with `DocumentConflict`, so you never overwrite their edit. Read it again, apply your change to the new content and retry.

The same operation renames and moves: pass `name` and `parentId` (the current value of whichever you keep) with `expectedVersion`, the `version` from `documents.get` or `documents.list`. `documents.delete` removes a document or folder for everyone in Avazal, also with `expectedVersion`. Slack is unchanged.

## History and restore

`documents.revisions` lists every saved revision, newest first, with who made it. `origin` is `native` for a save in Avazal, `draft` for an unpublished canvas edit and `remote` for a change made in Slack. Read one with `documents.get` and its `revisionId`.

`documents.update` with `restore` brings back an earlier revision. Pass the current `revisionId` as `expectedRevisionId`, and `draft.generation` as `expectedGeneration` (`0` when `draft` is `null`). On a canvas, the old text becomes your draft and nothing reaches Slack until you publish.

## Edit and publish a Slack canvas

A canvas is edited as a draft in Avazal, then published to Slack, so a half-finished edit never reaches the channel. `documents.get` on a canvas returns a `publish` block: `unpublished` says whether your draft differs from Slack, `generation` is the draft's version, `canWrite` says whether you may edit it, and `operation` is the latest publish.

1. Read the canvas with `documents.get`. Note `revisionId` and `draft.generation`, or `0` when there is no draft.
2. Call `documents.update` with the new `markdown`, `expectedRevisionId` and `expectedGeneration`. This saves your draft. Slack is unchanged.
3. Call `documents.publish`. It is [outward](https://docs.avazal.com/authentication.md#risk): everyone with access to the canvas sees the result.

```bash theme={null}
curl -X POST https://api.avazal.com/v1/documents.publish \
  -H "Authorization: Bearer $AVAZAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id": "doc_…", "expectedGeneration": 2, "bodyWrite": "replace-document", "idempotencyKey": "launch-notes-1"}'
```

`bodyWrite` is `replace-document` to replace the body, or `append-only` to only add to the end. Reuse the same `idempotencyKey` when you retry. The result is the document with its `publish` block; `publish.operation.state` is `queued` or `applying` while Slack applies it. Call `documents.get` with the operation's id as `operationId` until the state is `verified`, `conflict` or `failed`. Add `refresh: true` to read the canvas as Slack now has it.

If the canvas changed in Slack after your draft began, saving the draft fails with `DocumentConflict`. Read the canvas again, merge your change into its latest text, and call `documents.update` with `resolve: true`, the merged `markdown` and the fresh `revisionId`.

## Canvas comments

`comments.list` with a canvas as `target` returns its comment threads, each with its `anchor` text and `replies`. Add `thread` to read one thread's comments. `comments.create` starts a thread on a passage when you pass `anchor`, text copied from the canvas markdown, and answers in a thread when you pass `thread`. Both write with `text` or `content`, post as you, and are outward.

```bash theme={null}
avazal comments.create '{"target": "doc_…", "anchor": "Launch on the 12th", "text": "Can we move this a day?"}'
```

Comments use the `documents:read` and `documents:write` scopes here, and `tasks:read` and `tasks:write` on tasks.

## Public links

A canvas, a Slack List task or a document a run saved can have a public link that anyone can open on the Avazal web app without signing in. `shares.get` reads it and `shares.update` turns it on with `shared: true`, or off with `shared: false`. Turning it on again after turning it off makes a new link. Each takes a `target`:

* A canvas: its `doc_…` id, or `chcv_…/<file id>`.
* A Slack List task: its task id from `tasks.list`.
* A document a run saved: the `aart_…` id returned by `documents.save`.

The result's `url` is the link anyone can open while `shared` is true. Turning a link on or off is outward. Shares need the `read` or `write` scope of the target's concept: `documents`, `tasks`, or `automations` for a document a run saved.

## In MCP

Each operation on this page is an action of one MCP tool. The [tool catalogue](https://docs.avazal.com/mcp-tools.md) lists every tool with its fields.

| Operation | MCP tool |
| - | - |
| `documents.save` | `run (action save)` |
| `documents.list` | `search (type document)` |
| `documents.get` | `read (type document)` |
| `tasks.get` | `read (type task)` |
| `search.resolve` | `read (type link)` |
| `documents.create` | `document (action create)` |
| `documents.update` | `document (action update)` |
| `documents.delete` | `document (action delete)` |
| `documents.revisions` | `read (type revisions)` |
| `documents.publish` | `document (action publish)` |
| `comments.list` | `read (type comments)` |
| `comments.create` | `comment` |
| `shares.get` | `read (type share)` |
| `shares.update` | `link (action share)` |
| `tasks.list` | `search (type task)` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.