# Markdown ZIP export

Create an export request for one publication, inspect its state, and download a ZIP archive. The exported archive contains unarchived posts, authors, categories, and tags; it does not include other publication resources.

## Authentication

All routes require a bearer token and the listed export capability in the
selected publication and the effective workspace principal's active
membership. Current role defaults or custom selections determine export grants;
organization workspaces also apply current verified Management grants.

## Routes

| Route | Method | Capability | Required input | Optional input and behavior | Success result |
| --- | --- | --- | --- | --- | --- |
| `/export/start` | `POST` | `export.start` | Publication selector | `format` | Staged `export`. |
| `/export/status` | `POST` | `export.status` | `export_id` | Matching publication selector | `export`. |
| `/export/download` | `POST` | `export.download` | `export_id` | Matching publication selector | ZIP attachment. |
| `/export/cancel` | `POST` | `export.cancel` | `export_id` | Matching publication selector | Cancelled `export`. |

## Start and download

`format` defaults to and currently only accepts `markdown_zip`.

```bash
curl -sS https://api.blog.service.m7.org/v1/export/start \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"publication_slug":"engineering-notes","format":"markdown_zip"}'
```

```json
{
  "started": true,
  "export": {
    "export_id": "EXPORT_UUID",
    "publication_id": "PUBLICATION_UUID",
    "format": "markdown_zip",
    "state": "ready",
    "selection": { "content": "posts", "include_archived": false },
    "archive_filename": "engineering-notes-export-20260819-120000.zip",
    "summary": { "post_count": 12, "author_count": 2, "category_count": 3, "tag_count": 9 }
  }
}
```

Use `export_id` with status, download, and cancel. Download succeeds only while the export state is `ready`; it returns an `application/zip` attachment, not the JSON envelope. Use the `Content-Disposition` filename when saving the response. Cancel changes a ready request to `cancelled` and does not change publication content.

## Archive layout

```text
manifest.json
authors.json
categories.json
tags.json
posts/
  release-notes.md
```

Each post uses importer-compatible front matter. The archive reflects current unarchived data at download time, rather than a permanent snapshot taken at start.
