# Request an accounting export

> The exports.create operation: POST /api/v1/exports in the REST API and the exports_create tool in the MCP server.

Requests the legal entity's accounting export for a period: calendar days `from` to `to` (included) in the
entity's time zone, every brand of the entity, in the mode of the request. It is built in the background
(usually within a minute): poll `exports.get` until `status` is `ready`. Three CSV files (RFC 4180, UTF-8):

- **journal**: one row per ledger entry of every posted transaction effective in the period, with the brand,
  the Ownrecord account, the entity's general-ledger account from its mapping (`exports.gl_mapping.set`), debit
  or credit in the entry's currency (exact decimals) and what the transaction links to (payment, invoice and
  credit note numbers, refund, dispute). Each transaction balances per currency; all periods together sum to the
  trial balance;
- **invoice register**: every invoice issued in the period (numbers, dates, customer, totals, status);
- **credit-note register**: every credit note issued in the period, with its original invoice.

Download the files from the console (entity → Exports) for 30 days.

## At a glance

- **REST:** `POST /api/v1/exports`
- **MCP tool:** `exports_create`
- **Operation ID:** `exports.create`
- **Scope:** Legal entity
- **Permission:** `ledger:write`
- **Risk tier:** `write`
- **Dry run:** Supported (send `Ownrecord-Dry-Run: true`)
- **Idempotency:** `Idempotency-Key` required
- **Modes:** Test and live
- **Authentication:** API key with the `ledger:write` scope
- **Since:** M8

## Request

### Body

A JSON object (`Content-Type: application/json`):

| Field  | Type   | Required | Description                                                                 |
| ------ | ------ | -------- | --------------------------------------------------------------------------- |
| `from` | string | Yes      | The first day, in the legal entity's time zone (YYYY-MM-DD).                |
| `to`   | string | Yes      | The last day, included; at most 366 days after `from`, and not after today. |

## Response

`201 Created` with a JSON object:

| Field                 | Type                                                     | Description                                                                                          |
| --------------------- | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| `id`                  | `exp_…` ID                                               |                                                                                                      |
| `object`              | `"data_export"`                                          |                                                                                                      |
| `livemode`            | boolean                                                  |                                                                                                      |
| `entityId`            | `ent_…` ID                                               |                                                                                                      |
| `kind`                | one of `accounting`, `organization`                      |                                                                                                      |
| `status`              | one of `queued`, `running`, `ready`, `expired`, `failed` | `queued`, then `running`, then `ready` (files downloadable for 30 days, then `expired`) or `failed`. |
| `from`                | string                                                   | The first day covered, in the entity's time zone.                                                    |
| `to`                  | string                                                   | The last day covered (included).                                                                     |
| `timeZone`            | string                                                   |                                                                                                      |
| `requestedBy`         | object                                                   |                                                                                                      |
| `requestedBy.type`    | string                                                   |                                                                                                      |
| `requestedBy.id`      | string                                                   |                                                                                                      |
| `glMappingVersion`    | integer or null                                          | The general-ledger mapping used (0: none was set).                                                   |
| `files`               | array of object                                          |                                                                                                      |
| `files[].part`        | one of `journal`, `invoices`, `credit_notes`             |                                                                                                      |
| `files[].fileId`      | `file_…` ID                                              |                                                                                                      |
| `files[].filename`    | string                                                   |                                                                                                      |
| `files[].contentType` | string                                                   |                                                                                                      |
| `files[].size`        | integer                                                  |                                                                                                      |
| `files[].sha256`      | string                                                   |                                                                                                      |
| `files[].rows`        | integer                                                  | Data rows (without the header).                                                                      |
| `summary`             | object or null                                           |                                                                                                      |
| `failure`             | object or null                                           |                                                                                                      |
| `readyAt`             | date-time or null                                        |                                                                                                      |
| `expiresAt`           | date-time or null                                        |                                                                                                      |
| `createdAt`           | date-time                                                |                                                                                                      |
| `updatedAt`           | date-time                                                |                                                                                                      |
| `version`             | integer                                                  |                                                                                                      |

## Examples

### The third quarter

```http
POST /api/v1/exports
Authorization: Bearer or_test_…
Idempotency-Key: 3f1c9a52-7d0e-4b8f-9a61-0c2d5e8b7f14
Content-Type: application/json

{
  "from": "2026-07-01",
  "to": "2026-09-30"
}
```

Response (`201`):

```json
{
  "id": "exp_01m4tx5nj8emwbyf7y9vcf4aaa",
  "object": "data_export",
  "livemode": false,
  "entityId": "ent_01m4tx5nj8emwbyf7y9vcf47zm",
  "kind": "accounting",
  "status": "queued",
  "from": "2026-07-01",
  "to": "2026-09-30",
  "timeZone": "Europe/Zagreb",
  "requestedBy": {
    "type": "user",
    "id": "usr_01m4tx5nj8emwbyf7y9vcf47zk"
  },
  "glMappingVersion": null,
  "files": [],
  "summary": null,
  "failure": null,
  "readyAt": null,
  "expiresAt": null,
  "createdAt": "2026-10-02T08:00:00.000Z",
  "updatedAt": "2026-10-02T08:00:00.000Z",
  "version": 1
}
```

## Errors

| Code                                                                                             | HTTP status | When                                                                                                                     | What to do                                                                                                                                                      |
| ------------------------------------------------------------------------------------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`validation_failed`](https://ownrecord.io/docs/reference/errors.md#validation_failed)           | 400         | `from` or `to` isn't a calendar date.                                                                                    | Fix the fields listed in `details.issues` and send the request again.                                                                                           |
| [`export_period_invalid`](https://ownrecord.io/docs/reference/errors.md#export_period_invalid)   | 400         | `from` is after `to`, the period is longer than 366 days, or it ends after today in the entity's time zone.              | Give `from` and `to` as calendar dates (YYYY-MM-DD) in the entity's time zone, `from` on or before `to`, at most 366 days in all, and not ending in the future. |
| [`idempotency_key_reused`](https://ownrecord.io/docs/reference/errors.md#idempotency_key_reused) | 409         | The idempotency key was used before for another request.                                                                 | Use a new Idempotency-Key for a different request, or resend the original request unchanged.                                                                    |
| [`scope_required`](https://ownrecord.io/docs/reference/errors.md#scope_required)                 | 400         | The request names no legal entity (an org key without `Ownrecord-Entity`, or a brand key: exports belong to the entity). | Call the operation with credentials or a target at its level: an organization, a legal entity, a brand or the platform (`details.required_scope`).              |
| [`permission_denied`](https://ownrecord.io/docs/reference/errors.md#permission_denied)           | 403         | You can't export this entity's books or change its mapping (`ledger:write`: finance, owners and admins).                 | Ask an organization owner or admin for a role or scope that allows this action.                                                                                 |
| [`livemode_not_allowed`](https://ownrecord.io/docs/reference/errors.md#livemode_not_allowed)     | 403         | You have no live-mode access, so you can't use live exports.                                                             | Use test mode, or credentials for the target's mode. Developers need live access granted by an organization owner or admin.                                     |

It can also return these [common errors](https://ownrecord.io/docs/reference.md#common-errors): [`api_version_unsupported`](https://ownrecord.io/docs/reference/errors.md#api_version_unsupported), [`invalid_json`](https://ownrecord.io/docs/reference/errors.md#invalid_json), [`unsupported_media_type`](https://ownrecord.io/docs/reference/errors.md#unsupported_media_type), [`authentication_required`](https://ownrecord.io/docs/reference/errors.md#authentication_required), [`api_key_invalid`](https://ownrecord.io/docs/reference/errors.md#api_key_invalid), [`resource_not_found`](https://ownrecord.io/docs/reference/errors.md#resource_not_found), [`idempotency_key_required`](https://ownrecord.io/docs/reference/errors.md#idempotency_key_required), [`idempotency_in_progress`](https://ownrecord.io/docs/reference/errors.md#idempotency_in_progress), [`approval_required`](https://ownrecord.io/docs/reference/errors.md#approval_required), [`approval_rejected`](https://ownrecord.io/docs/reference/errors.md#approval_rejected), [`approval_expired`](https://ownrecord.io/docs/reference/errors.md#approval_expired), [`stale_approval`](https://ownrecord.io/docs/reference/errors.md#stale_approval), [`approval_policy_denied`](https://ownrecord.io/docs/reference/errors.md#approval_policy_denied), [`rate_limited`](https://ownrecord.io/docs/reference/errors.md#rate_limited), [`internal_error`](https://ownrecord.io/docs/reference/errors.md#internal_error).
