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

# Export Collection

> Export pre-computed markdown for every document in a collection.

## Overview

Exports markdown content for all documents in a collection. Supports NDJSON streaming (default) or a zip archive.

## Request

<ParamField path="id" type="string" required>
  Collection ID (`col-...`) or collection name.
</ParamField>

<ParamField query="format" type="string">
  `markdown` (default, NDJSON stream) or `zip` (one `.md` file per document).
</ParamField>

<RequestExample>
  ```bash theme={null}
  # NDJSON event stream
  curl -N "https://api.okrapdf.com/v1/collections/col-40da068481cf4f248853507cba6be611/export?format=markdown" \
    -H "Authorization: Bearer okra_YOUR_KEY"

  # Zip archive
  curl -L "https://api.okrapdf.com/v1/collections/col-40da068481cf4f248853507cba6be611/export?format=zip" \
    -H "Authorization: Bearer okra_YOUR_KEY" \
    -o collection-export.zip
  ```
</RequestExample>

### NDJSON Event Shapes

**`start`** -- first event in the stream:

```json theme={null}
{"type":"start","doc_count":3,"format":"markdown"}
```

**`result`** -- one per document:

```json theme={null}
{
  "type": "result",
  "doc_id": "doc-abc123",
  "file_name": "10k.pdf",
  "page_count": 2,
  "pages": [
    {"pageNumber": 1, "content": "# Page 1 markdown", "vendor": "okra"},
    {"pageNumber": 2, "content": "# Page 2 markdown", "vendor": "okra"}
  ]
}
```

**`done`** -- final success event:

```json theme={null}
{"type":"done","completed":3,"failed":0,"total_pages":12}
```

**`error`** -- terminal failure:

```json theme={null}
{"type":"error","error":"Collection export failed"}
```
