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

# Export

> Render a document, page or table to markdown, PDF, HTML, CSV or JSON and fetch it through a 15-minute download URL.

Render a document, page or table to a file and fetch it through a short-lived URL.

| Tool                                  | Scope            | Kind      |
| ------------------------------------- | ---------------- | --------- |
| [`export_document`](#export-document) | `documents:read` | read-only |

## export\_document

**Scope:** `documents:read` (step-up) · **Kind:** read-only · **Annotations:** `readOnlyHint: true`, `destructiveHint: false`, `openWorldHint: false`

> Render a document (markdown, pdf), page (html), or table (csv, json,
> markdown) to a file and get a short-lived download URL (\~15 minutes; fetch
> it promptly). The file is a snapshot of the version it names — re-export
> after editing. Exporting never changes the artifact.

### Parameters

<ParamField body="document_id" type="string" required>
  The artifact id of a document, page or table.
</ParamField>

<ParamField body="format" type="'markdown' | 'html' | 'pdf' | 'csv' | 'json'" required>
  Which formats apply depends on the artifact kind:

  | Kind       | Formats                   |
  | ---------- | ------------------------- |
  | `document` | `markdown`, `pdf`         |
  | `html_app` | `html`                    |
  | `table`    | `csv`, `json`, `markdown` |
</ParamField>

### Returns

<ResponseField name="download_url" type="string">
  A capability URL on the server's `/files/` route. Valid for 15 minutes;
  access is re-checked at download time.
</ResponseField>

<ResponseField name="expires_at" type="number">Milliseconds since epoch.</ResponseField>
<ResponseField name="filename" type="string">Derived from the title slug and format, for example `q3-launch-plan.pdf`.</ResponseField>

<ResponseField name="media_type" type="string" />

<ResponseField name="byte_size" type="number" />

<ResponseField name="source_version" type="number">The artifact version the file captures.</ResponseField>
<ResponseField name="page_count" type="number">PDF only.</ResponseField>
<ResponseField name="warnings" type="string[]">Renderer warning codes, if any.</ResponseField>

Text: `Exported "<title>" as <filename> (<media type>, <bytes> bytes). Download within 15 minutes: <url>`

### Permissions and side effects

* Needs `documents:read` and any role on the artifact.
* Uses the same renderer and cache as the app's Export menu, so a second
  export of an unchanged version is served from cache.
* Never changes the artifact. Recorded in the agent activity history.
* Exports are not delivered into the pod as attachments; the URL is the
  only output.

### Errors

| `error`              | Text                                                                                                                                  | Cause                                      |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| —                    | `Tool failed: \`format\` must be one of markdown \| html \| pdf \| csv \| json\`                                                      | Unknown format                             |
| `format_unavailable` | `That artifact cannot be exported as <Format> — documents export as markdown or pdf, pages as html, tables as csv, json or markdown.` | Format does not apply to the kind          |
| `export_disabled`    | `File export is turned off for this workspace.`                                                                                       | Workspace setting                          |
| `source_missing`     | `That artifact has nothing in it to export yet.`                                                                                      | Empty artifact                             |
| `still_rendering`    | `The file is still being produced — try once more shortly.`                                                                           | Concurrent render in progress              |
| `render_failed`      | `The file could not be produced.`                                                                                                     | Renderer error                             |
| —                    | `Tool failed: … Artifact not found`                                                                                                   | Not visible, wrong workspace or no such id |

### Example

**Request**

```json theme={null}
{
  "name": "export_document",
  "arguments": { "document_id": "k97fq2example000000000000000000", "format": "pdf" }
}
```

**Response (structuredContent)**

```json theme={null}
{
  "filename": "q3-launch-plan.pdf",
  "media_type": "application/pdf",
  "byte_size": 48213,
  "source_version": 43,
  "page_count": 3,
  "warnings": [],
  "download_url": "https://mcp.sidecars.ai/files/r3nd1t10nexample.pdf?token=…",
  "expires_at": 1757161629000
}
```

<Note>
  The exact shape of the download URL is an implementation detail and may
  differ from the example; treat it as opaque and fetch it as-is.
</Note>
