# Document

URL: /business/nouns/document · Id: `noun:document`

> A Document is structured, versioned material in one of three forms, a document, a deck, or a sheet, rendered to any format.

A Document is structured, versioned material in one of three forms, a document, a deck, or a sheet, rendered to any format.

## Properties
| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `form` | `string` | Yes | One of `document`, `deck`, or `sheet`. |

## Object
```json
{
  "$id": "https://api.sb/routewise.dev/documents/document_1",
  "$type": "Document",
  "form": "document"
}
```

## Relationships
- <a id="rel-exports-to"></a>A Document **exports to** many [Files](/business/nouns/file): each rendering of a Document to a format, such as PDF, is stored as a [File](/business/nouns/file). `exportsTo`, inverse [`exportOf`](/business/nouns/file#rel-export-of).
- <a id="rel-generated-from"></a>A Document **is generated from** one [Template](/business/nouns/template): a [Template](/business/nouns/template) fills its variables from the graph to generate a Document, such as a proposal or an invoice. `generatedFrom`, inverse [`generates`](/business/nouns/template#rel-generates).

## Verbs
| Verb | Description | Subject | Event | Class |
| --- | --- | --- | --- | --- |
| [Document.render](/business/nouns/document/render) | Render produces a file from a Document in the format the reader asks for. | [Agent](/business/nouns/agent) | [`Document.rendered`](/business/events/Document.rendered) | None. |
| <a id="create"></a>[Document.create](/business/nouns/document/create) | Creates a Document. Inherited from [Noun](/business/nouns/noun). | None. | `Document.created` | Two-way: `try`, `send`, `do` |
| <a id="get"></a>[Document.get](/business/nouns/document/get) | Returns one Document by id. Inherited from [Noun](/business/nouns/noun). | None. | None. | Read: `try`, `do` |
| <a id="list"></a>[Document.list](/business/nouns/document/list) | Returns Documents, newest first, one page at a time. Inherited from [Noun](/business/nouns/noun). | None. | None. | Read: `try`, `do` |
| <a id="update"></a>[Document.update](/business/nouns/document/update) | Changes the given properties of a Document. Inherited from [Noun](/business/nouns/noun). | None. | `Document.updated` | Two-way: `try`, `send`, `do` |
| <a id="delete"></a>[Document.delete](/business/nouns/document/delete) | Deletes a Document; its history is kept. Inherited from [Noun](/business/nouns/noun). | None. | `Document.deleted` | One-way: `send`, `do` |

## Permissions
Which Access level may call each Verb. One-way Verbs wait their delay window.

| Operation | `owner` | `admin` | `member` | `viewer` |
| --- | --- | --- | --- | --- |
| `Document.create` | Yes | Yes | Yes | No |
| `Document.get` | Yes | Yes | Yes | Yes |
| `Document.list` | Yes | Yes | Yes | Yes |
| `Document.update` | Yes | Yes | Yes | No |
| `Document.delete` | Yes | Yes | Yes | No |
| `Document.render` | Yes | Yes | Yes | No |

## Call it

**Ask**

```text
Render the latest document.
```

**API**

```bash
curl -X POST https://api.sb/ledgerlark.com/documents/document_1/render \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"format":"Example format"}'
```

```json
{
  "api": "https://api.sb/ledgerlark.com",
  "file": "https://ledgerlark.com",
  "document": {
    "$id": "https://api.sb/ledgerlark.com/documents/document_1",
    "$type": "Document",
    "form": "document"
  },
  "action": {
    "$id": "https://api.sb/ledgerlark.com/actions/action_1",
    "operation": "Document.render",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/ledgerlark.com/actions/action_1"
  }
}
```

**SDK**

```ts
import { $ } from 'startup-builder'

const { file, document } = await $.Document.render({ document: 'document_1', format: 'Example format' })
```

**CLI**

```bash
npx startup-builder do Document.render --json '{"document":"document_1","format":"Example format"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Document.render({ document: 'document_1', format: 'Example format' })"
  }
}
```

## Example
The quarterly investor update is a Document in deck form. The same Document renders to PDF for email and to Markdown for an [Agent](/business/nouns/agent).