## Start an auditor export (tenant:dms:admin)

`POST /api/dms/v1/exports`

Module: DMS · operationId: `createExport` · Tag: Exports · Auth: access token (`Authorization: Bearer <accessToken>`)

Selects the documents created in `from`…`to` (dates are whole days, UTC; at most 11 years),
optionally only of the given document types, and builds a ZIP with `index.xml`, `index.csv`,
the files and their hashes in the background. Files the malware scan found infected are
listed in the index but not included. Poll `getExport` until `status` is `DONE`
(or `FAILED`), then download it.

### Request body

`application/json` (required)

- `from` (string, required): Date (`YYYY-MM-DD`) or RFC 3339 timestamp
- `to` (string, required): Date (`YYYY-MM-DD`, inclusive) or RFC 3339 timestamp
- `categories` (array of string): Only these document types; empty = all

Example:

```json
{
  "categories": [
    "incoming_document",
    "contract"
  ],
  "from": "2025-01-01",
  "to": "2025-12-31"
}
```

### Responses

- **202** Started (status PENDING) (`application/json`)
- **400** Error (`application/json`)
- **503** Error (`application/json`)

Fields of the 202 answer:

- `categories` (array of string, required): Document types included; empty: all
- `createdAt` (string (date-time), required): Start time
- `createdBy` (string, required): Who started the export
- `customerNo` (string, required): Customer number of the tenant
- `documentCount` (integer, required): Documents in the export
- `from` (string (date-time), required): Documents created from
- `id` (string (uuid), required): Export id
- `sizeBytes` (integer (int64), required): Size of the ZIP in bytes
- `status` (string, required): PENDING while it is built (one of `PENDING`, `DONE`, `FAILED`)
- `tenantName` (string, required): Tenant name
- `to` (string (date-time), required): Documents created until
- `completedAt` (string (date-time)): Time the export finished
- `error` (string): Why the export failed
- `sha256` (string): SHA-256 of the ZIP once done

Example 202 answer:

```json
{
  "categories": [
    "incoming_document",
    "outgoing_invoice"
  ],
  "completedAt": "2026-02-03T09:06:41Z",
  "createdAt": "2026-02-03T09:00:00Z",
  "createdBy": "christina.adler@muster-it.example",
  "customerNo": "99999",
  "documentCount": 1284,
  "from": "2025-01-01T00:00:00Z",
  "id": "9b1d3f5b-7c9e-4a1b-8d3f-5b7c9e1a3b5d",
  "sha256": "c4a9e1f7b3d5028e6a4c9f1b7d3e5a2c8f0b6d4e2a9c7f5b1d3e8a6c0f4b2d9e",
  "sizeBytes": 412318720,
  "status": "DONE",
  "tenantName": "DEMO",
  "to": "2025-12-31T23:59:59Z"
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/dms/v1/exports' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"categories":["incoming_document","contract"],"from":"2025-01-01","to":"2025-12-31"}'
```
