# Export Operation API

Source: https://userguide.qualytics.io/operations/export-operation/api/

This page provides payload examples for triggering, scheduling, re-running, and polling Export Operations. Replace the placeholder values with data specific to your setup.

All endpoints use the base URL of your Qualytics deployment (e.g., `https://your-instance.qualytics.io/api`).

> **Tip: Interactive API reference**
>
> For the full, interactive API reference (request schemas, response examples, and an in-browser request runner), visit [demo.qualytics.io/api/docs](https://demo.qualytics.io/api/docs).

> **Note: Permissions**
>
> Triggering, scheduling, updating, deleting, and re-running Export Operations all require the **Editor** team permission on the source datastore. Reading an operation or schedule requires **Reporter**. Workspace **Admin** bypasses team-permission checks. See [Permissions](https://userguide.qualytics.io/operations/export-operation/deep-dive/permissions/) for the full matrix.

## Trigger an Export Operation

Trigger a one-shot Export Operation. The call returns as soon as the work is enqueued; the operation processes asynchronously and writes its output to the linked enrichment destination. Poll `GET /operations/{id}` to follow status.

**Endpoint:** `POST /operations/run`

**Permission:** Editor on the source datastore.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | Yes | Must be `"export"`. |
| `datastore_id` | integer | Yes | The source datastore to export from. Must already have an enrichment destination linked. |
| `asset_type` | string | Yes | One of `"anomalies"`, `"checks"`, `"profiles"`. |
| `container_ids` | `list[int]` | No | Container IDs to include. Ignored if `container_tags` is also set. Both null = "All containers". |
| `container_tags` | `list[string]` | No | Container tag names to include. Takes precedence over `container_ids` when both are set. |
| `include_deleted` | bool | No | Include deleted assets in the export. Defaults to `false`. |
| `include_masked` | bool | No | Reveal masked values in the export. Defaults to `false`. Editor permission required. |
| `merge_source_records` | bool | No | Anomalies only. Write each anomaly beside the source records it flagged, to `_<datastore_name>_export_anomaly_records`, instead of the regular Anomalies output. Defaults to `false`. Rejected with `422 Unprocessable Entity` for other asset types. |

> **Note: Large exports**
>
> An export is not rejected for its size when you trigger it: the request creates an operation whatever the scope. Size safeguards (50,000,000 records and 4 GB of compressed data per export, 32 MB per record, by default) are checked while the export runs. An export that exceeds one finishes with `result = failure` and its `message` names the limit. Narrow `container_ids` or `container_tags` and split the export if that happens. See [Export size limits](https://userguide.qualytics.io/operations/export-operation/deep-dive/how-it-works/#export-size-limits).

> **Note: Container selection**
>
> If both `container_ids` and `container_tags` are provided on a trigger request, `container_tags` takes precedence and `container_ids` is ignored. Provide only one. (The [Schedule an Export Operation](https://userguide.qualytics.io/operations/export-operation/api/#schedule-an-export-operation) endpoint is stricter: it rejects a request that sets both with `422 Unprocessable Entity`.)

> **Example: Trigger by container IDs**
>
> **Request**:
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/operations/run" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "type": "export",
>     "datastore_id": 42,
>     "asset_type": "checks",
>     "container_ids": [101, 102, 103],
>     "include_deleted": false,
>     "include_masked": false
>   }'
> ```
>
> **Response** (200 OK):
>
> ```json
> {
>   "id": 12345,
>   "type": "export",
>   "datastore": { "id": 42, "name": "Sales Warehouse" },
>   "asset_type": "checks",
>   "result": "queued",
>   "start_time": "YYYY-MM-DDTHH:MM:SS.ssssssZ",
>   "end_time": null,
>   "triggered_by": "user@example.com"
> }
> ```

> **Example: Trigger by container tag**
>
> **Request**:
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/operations/run" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "type": "export",
>     "datastore_id": 42,
>     "asset_type": "profiles",
>     "container_tags": ["pii", "finance"],
>     "include_masked": true
>   }'
> ```
>
> **Response** (200 OK):
>
> ```json
> {
>   "id": 12346,
>   "type": "export",
>   "datastore": { "id": 42, "name": "Sales Warehouse" },
>   "asset_type": "profiles",
>   "result": "queued",
>   "include_masked": true
> }
> ```

> **Example: Trigger across all containers**
>
> **Request**:
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/operations/run" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "type": "export",
>     "datastore_id": 42,
>     "asset_type": "anomalies"
>   }'
> ```
>
> **Response** (200 OK):
>
> ```json
> {
>   "id": 12347,
>   "type": "export",
>   "datastore": { "id": 42, "name": "Sales Warehouse" },
>   "asset_type": "anomalies",
>   "result": "queued"
> }
> ```

## Poll an Operation

Read the current state of a previously triggered Export Operation.

**Endpoint:** `GET /operations/{id}`

**Permission:** Reporter on the source datastore.

The `result` field transitions through `queued` → `running` → one of `success`, `failure`, or `aborted`. An export that matches no containers still ends in `success`, and its `message` says no containers matched.

> **Example: Poll status**
>
> **Request**:
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/operations/12345" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Response** (200 OK, excerpt):
>
> ```json
> {
>   "id": 12345,
>   "type": "export",
>   "datastore": { "id": 42, "name": "Sales Warehouse" },
>   "asset_type": "checks",
>   "result": "success",
>   "start_time": "YYYY-MM-DDTHH:MM:SS.ssssssZ",
>   "end_time": "YYYY-MM-DDTHH:MM:SS.ssssssZ",
>   "message": null,
>   "triggered_by": "user@example.com"
> }
> ```

## Re-run an Operation

Re-run a previously completed Export Operation. The new operation inherits the original's parameters and produces a fresh record. The schedule association from the original is **not** carried over.

**Endpoint:** `PUT /operations/rerun/{id}`

**Permission:** Editor on the source datastore.

> **Example: Re-run a completed operation**
>
> **Request**:
>
> ```bash
> curl -X PUT "https://your-instance.qualytics.io/api/operations/rerun/12345" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Response** (200 OK):
>
> ```json
> {
>   "id": 12399,
>   "type": "export",
>   "datastore": { "id": 42, "name": "Sales Warehouse" },
>   "asset_type": "checks",
>   "result": "queued"
> }
> ```

> **Warning: Re-running a running operation**
>
> Attempting to re-run an operation whose original has not finished yet returns `415 Unsupported Media Type`. Wait for the original to reach `success`, `failure`, or `aborted` before re-running.

## Schedule an Export Operation

Create a recurring Export Operation schedule. Schedules run the configured payload on the cron cadence in the chosen IANA timezone.

**Endpoint:** `POST /operations/schedule`

**Permission:** Editor on the source datastore.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | Yes | Must be `"export"`. |
| `name` | string | No | Friendly label for the schedule. |
| `datastore_id` | integer | Yes | The source datastore to export from. |
| `asset_type` | string | Yes | One of `"anomalies"`, `"checks"`, `"profiles"`. |
| `container_ids` / `container_tags` | list | No | Container selection (mutually exclusive). |
| `include_deleted` | bool | No | Defaults to `false`. |
| `include_masked` | bool | No | Defaults to `false`. |
| `merge_source_records` | bool | No | Anomalies only. Each scheduled run writes `_<datastore_name>_export_anomaly_records` instead of the regular Anomalies output. Defaults to `false`. Rejected with `422 Unprocessable Entity` for other asset types. |
| `crontab` | string | Yes | 5-field cron expression (e.g. `0 0 * * *` for daily at 00:00). |
| `timezone` | string | No | IANA timezone name (e.g. `America/New_York`). Defaults to `UTC` when omitted. |
| `deactivated` | bool | No | When `true`, the schedule is created in a deactivated state. Defaults to `false`. |

> **Example: Schedule a daily Quality Check export at 00:00 in UTC**
>
> **Request**:
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/operations/schedule" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "type": "export",
>     "name": "Daily checks export",
>     "datastore_id": 42,
>     "asset_type": "checks",
>     "include_deleted": false,
>     "include_masked": false,
>     "crontab": "0 0 * * *",
>     "timezone": "UTC"
>   }'
> ```
>
> **Response** (200 OK):
>
> ```json
> {
>   "id": 87,
>   "name": "Daily checks export",
>   "type": "export",
>   "datastore": { "id": 42, "name": "Sales Warehouse" },
>   "asset_type": "checks",
>   "crontab": "0 0 * * *",
>   "timezone": "UTC",
>   "deactivated": false
> }
> ```

## Update a Schedule

Modify an existing schedule. You can change the cron expression, timezone, name, asset type, or any other field listed above.

**Endpoint:** `PUT /operations/schedule/{id}`

**Permission:** Editor on the source datastore.

> **Example: Update the cron expression of an existing schedule**
>
> **Request**:
>
> ```bash
> curl -X PUT "https://your-instance.qualytics.io/api/operations/schedule/87" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "type": "export",
>     "name": "Daily checks export",
>     "datastore_id": 42,
>     "asset_type": "checks",
>     "crontab": "0 6 * * *",
>     "timezone": "America/New_York"
>   }'
> ```
>
> **Response** (200 OK):
>
> ```json
> {
>   "id": 87,
>   "name": "Daily checks export",
>   "type": "export",
>   "datastore": { "id": 42, "name": "Sales Warehouse" },
>   "asset_type": "checks",
>   "crontab": "0 6 * * *",
>   "timezone": "America/New_York",
>   "deactivated": false
> }
> ```

> **Note: Deactivation preserves the cron expression**
>
> Deactivating a schedule keeps its cron expression. Reactivate it later to resume the same cadence without re-entering anything.

## Delete a Schedule

Remove a schedule. The operation history of past runs is preserved; only the schedule itself is removed.

**Endpoint:** `DELETE /operations/schedule/{id}`

**Permission:** Editor on the source datastore.

> **Example: Delete a schedule**
>
> **Request**:
>
> ```bash
> curl -X DELETE "https://your-instance.qualytics.io/api/operations/schedule/87" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Response** (204 No Content): empty body.

*Last updated: October 9, 2026.*
