REST API
Use the filters from a working list request to export the same selection of records. Choose the output format according to the application that will read the file.
Open the API Explorer at /docs/api on your Open Mercato instance to inspect request and response schemas or try a call with an API key.
Most list endpoints in Open Mercato can return a downloadable file instead of a paginated JSON page. Export is a cross-cutting capability of the CRUD factory: you do not call a separate /export route – you add a format query parameter to the same list URL you already use. This page documents that contract plus the two bespoke export endpoints (custom entity records and audit logs).
export BASE_URL="http://localhost:3000/api"
export API_KEY="<paste your API key secret here>"
All curl examples reuse these variables. Provision the API key with the same features the underlying list endpoint requires (see Managing API keys).
?format=csv (or json, xml, markdown) to any list endpoint. When format is present, the handler serializes the rows to a file and returns them as an attachment instead of the usual { items, total, page, pageSize, totalPages } body.search, sortField/sortDir, ?ids=, and every custom-field (cf_*) filter apply. "Export what you see" is the mental model.GET guard (requireAuth + requireFeatures). There is no separate export permission, and tenant/organization scoping is applied exactly as for a normal list.The serializers live in packages/shared/src/lib/crud/exporters.ts; the CRUD factory wires them into every list route in packages/shared/src/lib/crud/factory.ts.
Export is enabled by default on every list endpoint built with makeCrudRoute. A route only turns it off with list.export.enabled = false, or narrows the offered formats with list.export.formats (see Configuring export on a route).
| Parameter | Values | Description |
|---|---|---|
format | csv | json | xml | markdown | Required to trigger an export. Case-insensitive; MIME aliases (application/json, application/xml, text/markdown) and md are also accepted. An unknown/unavailable value falls through to a normal JSON list response. |
exportScope | view (default) | full | view exports the grid projection (the same columns the list shows). full exports the full raw records – all fields, including flattened custom fields, with internal _meta/enricher fields removed. export_scope is accepted as a snake-case alias. |
full | true | false | Alias for exportScope=full. |
all | true | false | Bypasses pagination; the admin UI sets it on full exports. |
Every filter, search, and sort parameter the list endpoint already supports also applies to the export.
format | Content-Type | File extension |
|---|---|---|
csv | text/csv; charset=utf-8 | .csv |
json | application/json; charset=utf-8 | .json |
xml | application/xml; charset=utf-8 | .xml |
markdown | text/markdown; charset=utf-8 | .md |
", ,, or newlines are quoted). The delimiter is fixed at ,.<records> document with one <record> per row; tags are sanitized from the field names.The body is the serialized file. Two headers describe it:
content-type – per the table above.content-disposition: attachment; filename="<name>.<ext>" – the filename defaults to the entity name, with a _full suffix on full-scope exports (for example people.csv or people_full.json). A route can override it via list.export.filename.When the query index backing the list is known to be incomplete, the response also carries an x-om-partial-index header with a JSON payload describing the gap, so clients can warn that the export may be missing rows.
Export the current filtered view of a list as CSV:
curl -X GET "$BASE_URL/customers/people?format=csv&search=acme&sortField=created_at&sortDir=desc" \
-H "X-Api-Key: $API_KEY" \
-o people.csv
Export full raw records as JSON:
curl -X GET "$BASE_URL/customers/people?format=json&exportScope=full&all=true" \
-H "X-Api-Key: $API_KEY" \
-o people_full.json
Export a specific subset by id as Markdown:
curl -X GET "$BASE_URL/catalog/products?format=markdown&ids=$PRODUCT_A,$PRODUCT_B" \
-H "X-Api-Key: $API_KEY" \
-o products.md
The same pattern works for any makeCrudRoute list, e.g. catalog/products, sales/<document>, customers/companies, and customers/deals.
There is no per-request column-selection parameter. The exported columns are fixed by the route:
view scope uses list.export.columns if configured, otherwise the legacy list.csv headers/rows, otherwise every key on the projected record.full scope emits every field on the raw record (custom-field cf_ prefixes stripped), minus _meta and _-prefixed enricher fields, which are always removed from exports.Custom (EAV) entity records have their own list endpoint, and it supports the same format parameter. See the Entities & Custom Fields API for the full endpoint.
GET /entities/recordsentities.records.viewentityId (which custom entity to export)format=csv|json|xml|markdown, exportScope=full, full=true, all=true – plus the endpoint's own paging, sorting, search, and cf_* filters.<entityId>[_full].<ext>.curl -X GET "$BASE_URL/entities/records?entityId=example.todo&format=csv" \
-H "X-Api-Key: $API_KEY" \
-o todos.csv
Implementation: packages/core/src/modules/entities/api/records.ts.
The audit-log changelog has a dedicated export endpoint that always returns CSV.
GET /audit-logs/actions/exportaudit_logs.view_self (holders of audit_logs.view_tenant can widen the scope to other actors and organizations; without it the export is scoped to the caller's own actions)format parameter.changelog-export.csvWhen, User, Action, Field, Old Value, New Value, Source (one row per field change, or a single summary row when an action recorded no field-level changes).Filter parameters (all optional):
| Parameter | Description |
|---|---|
organizationId | Limit to a specific organization (must be in the caller's allowed scope). |
actorUserId | Filter by actor. Single UUID or comma-separated list (tenant administrators only). |
resourceKind / resourceId | Filter by resource type (e.g. order, product) and/or a specific record. |
actionType | create, edit, delete, assign, … – single value or comma-separated list. |
fieldName | Only entries where the given field(s) changed. |
includeRelated | true/false – include changes to child entities linked via parent resource. |
undoableOnly | true/false – only undoable actions. |
limit | Max rows (default 1000, capped at 1000). |
sortField | createdAt | user | action | field | source. |
sortDir | asc | desc. |
before / after | ISO-8601 timestamps bounding the range. |
curl -X GET "$BASE_URL/audit-logs/actions/export?resourceKind=order&actionType=edit,delete&after=2026-01-01T00:00:00Z" \
-H "X-Api-Key: $API_KEY" \
-o changelog.csv
Implementation: packages/core/src/modules/audit_logs/api/audit-logs/actions/export/route.ts.
Module authors control export behavior through the list.export block passed to makeCrudRoute. See the CRUD Factory reference for the full option set.
list: {
entityId: E.customers.person,
export: {
enabled: true, // default true; set false to disable export entirely
formats: ['csv', 'json'], // default: all four; restrict the offered set
filename: 'customers_export', // string or (format) => string
columns: [ // view-scope column projection
{ field: 'id', header: 'ID' },
{ field: 'display_name', header: 'Name' },
{ field: 'cf:priority', header: 'Priority' },
],
batchSize: 1000, // rows per in-request fetch page (clamped 100–10000)
},
}
,; there is no delimiter option._-prefixed) and internal _meta are never included in exports.data_sync module also uses the word "export" to mean pushing data out to an external system. That is a separate, asynchronous feature (POST /api/data_sync/run) documented in the Integrations & Data Sync API – not a file download.Previous: Entities and custom fields API · Next: Feature toggle API