# Volumetric Check API

Source: https://userguide.qualytics.io/data-quality-checks/volumetric/api/

This page documents how to create and manage a Volumetric check via the REST API. The check uses the standard Quality Checks endpoints: set `rule` to `volumetric` and configure the comparison under `properties`. The rule reads the container itself, so `fields` is not used. All endpoints share the base URL of your deployment (for example, `https://your-instance.qualytics.io/api`) and require a Bearer token.

> **Tip**
>
> For complete API documentation, including request and response schemas, visit the [API docs](https://userguide.qualytics.io/api/docs).

> **Note: Permissions**
>
> All endpoints require the **Member** role plus a team permission on the check's datastore: **Reporter** to read, **Author** to create or update an Active check, archive, or delete, and **Drafter** to create or update a Draft. See [Permissions](https://userguide.qualytics.io/data-quality-checks/volumetric/deep-dive/permissions/) for the full matrix.

## The `properties` object

Volumetric carries its rule-specific configuration under `properties`:

| Field | Required | Type | Description |
| --- | --- | --- | --- |
| `comparison` | Yes | `string` | `"Absolute Value"`, `"Absolute Change"`, or `"Percentage Change"`. See [Comparisons](https://userguide.qualytics.io/data-quality-checks/volumetric/deep-dive/comparisons/). |
| `window_size` | Yes | `integer` | The Measurement Period, in days. |
| `min` | One of `min` / `max` | `number` | The lower limit. A row count for Absolute Value, a row movement for Absolute Change, or a decimal fraction for Percentage Change (`-0.2` means a 20% decrease). |
| `max` | One of `min` / `max` | `number` | The upper limit, in the same unit as `min`. |

At least one of `min` and `max` is required, and `min` cannot be greater than `max`. Either violation returns `422`. Percentage Change limits are decimals in the API, while the app takes them in percent.

## Create

**Endpoint:** `POST /api/quality-checks`

**Permission:** Member role + **Author** team permission on the container's datastore (**Drafter** when `status` is `"Draft"`).

> **Example: Create a Volumetric check (every accepted field)**
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/quality-checks" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>       "description": "ORDERS must gain at least one row per daily load.",
>       "rule": "volumetric",
>       "fields": [],
>       "container_id": 145,
>       "filter": null,
>       "properties": {"comparison": "Absolute Change", "window_size": 1, "min": 1, "max": null},
>       "tags": ["daily-load"],
>       "additional_metadata": {"runbook": "https://wiki.example.com/orders-load"},
>       "template_id": null,
>       "status": "Active",
>       "owner_id": 7,
>       "default_anomaly_assignee_id": 12
>   }'
> ```

### Field notes

| Field | Required | Notes |
| --- | --- | --- |
| `description` | Yes | Free-text description shown in the UI. |
| `rule` | Yes | Must be `"volumetric"`. |
| `fields` | No | Volumetric does not evaluate a field. Send an empty array `[]` or omit. |
| `container_id` | Yes | ID of the container (table or file) whose row count is checked. |
| `filter` | No | Not supported by this rule. Send `null` or omit it. A non-empty expression is rejected with `422`. |
| `properties` | Yes | Object holding the comparison, the Measurement Period, and the limits. See [above](https://userguide.qualytics.io/data-quality-checks/volumetric/api/#the-properties-object). |
| `tags` | No | List of tag names applied to the check. Anomalies the check produces inherit them. |
| `additional_metadata` | No | Free-form key-value pairs (typically links to catalog entries, tickets, governance records). |
| `template_id` | No | ID of a Check Template whose rule type is Volumetric. The template then controls the check's properties. Send `null` or omit it to configure the check directly. |
| `status` | No | `"Active"` (default) or `"Draft"`. Draft checks are not evaluated by Scans. |
| `owner_id` | No | ID of the user who owns the check. Defaults to the user creating the check when omitted. |
| `default_anomaly_assignee_id` | No | ID of the user automatically assigned to anomalies produced by the check. |

Two payload fields exist for other rule types but do not apply here:

- `coverage` is not supported. The rule reads the container's row count, not its rows, so there is no per-row violation rate. Any value other than `1` is rejected with `422`.
- `anomaly_message_field` is ignored. Volumetric emits a Shape Anomaly only, and Shape Anomalies always use the fixed message.

## Read

**Endpoint:** `GET /api/quality-checks/{id}`

**Permission:** Member role + **Reporter** team permission on the check's datastore.

> **Example: Retrieve a check by ID**
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/quality-checks/101" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```

The response's `inferred` field is `true` for an AI Managed check. Its `last_asserted` field is empty until a Scan has asserted the check.

## Update

**Endpoint:** `PUT /api/quality-checks/{id}`

**Permission:** Member role + **Author** team permission on the check's datastore (**Drafter** when the check stays Draft).

Every `PUT` requires `description` and the full `properties` object, including `comparison`, `window_size`, and at least one of `min` or `max`. Repeat the check's current `properties` even when changing only its description, tags, or other metadata: a request without them returns `422`. Partial property updates are not merged.

> **Example: Add an upper limit to catch duplicated loads**
>
> ```bash
> curl -X PUT "https://your-instance.qualytics.io/api/quality-checks/101" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "description": "ORDERS must gain between 1 and 50000 rows per daily load.",
>     "properties": {"comparison": "Absolute Change", "window_size": 1, "min": 1, "max": 50000}
>   }'
> ```

A `PUT` can update most fields on an existing Volumetric check. Three values stay immutable: the rule type, the container the check is attached to, and `template_id`. The comparison becomes immutable too, once a Scan has included the check: sending a different `comparison` then returns `409`. Updating any property of an AI Managed check sets `inferred` to `false`, which stops automatic updates.

> **Info: Editable vs Immutable on PUT**
>
> **Editable**
>
> - `description`
> - `properties.window_size`
> - `properties.min`
> - `properties.max`
> - `properties.comparison` (only until the first Scan that includes the check)
> - `tags`
> - `additional_metadata`
> - `status`
> - `owner_id`
> - `default_anomaly_assignee_id`
>
> **Immutable**
>
> - `rule`
> - `container_id`
> - `template_id`

## Delete

**Endpoint:** `DELETE /api/quality-checks/{id}`

**Permission:** Member role + **Author** team permission on the check's datastore.

Three query parameters control what happens, mirroring the two-stage flow in the UI:

| Parameter | Default | Description |
| --- | --- | --- |
| `archive` | `true` | When `true`, the check is archived and can be restored later. When `false`, the check is permanently deleted. |
| `status` | `Discarded` | The archive resolution: `Discarded` (no longer relevant) or `Invalid` (wrong and suppressed from future AI generation). Only used when `archive=true`. |
| `delete_anomalies` | `true` | Whether to permanently delete the anomalies the check produced. A permanent delete (`archive=false`) always removes them. |

> **Example: Archive a check, keeping its anomalies**
>
> ```bash
> curl -X DELETE "https://your-instance.qualytics.io/api/quality-checks/101?archive=true&status=Discarded&delete_anomalies=false" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```

> **Example: Delete a check permanently**
>
> ```bash
> curl -X DELETE "https://your-instance.qualytics.io/api/quality-checks/101?archive=false" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```

## Error responses

| Status | Description |
| --- | --- |
| `400 Bad Request` | A business-logic conflict prevents the operation (for example, changing properties while the check is archived, or switching an archived check between `Discarded` and `Invalid`). |
| `401 Unauthorized` | Missing or invalid API token. |
| `403 Forbidden` | The caller lacks the required team permission on the check's datastore. |
| `404 Not Found` | The check ID does not exist. |
| `409 Conflict` | An Active Volumetric check with the same `comparison` and `window_size` already exists on the container, or a `PUT` tried to change the `comparison` of a check that a Scan has already included. |
| `422 Unprocessable Entity` | The payload fails schema validation (for example, `description` missing on `PUT`, neither `min` nor `max` set, `min` greater than `max`, or a non-empty `filter`). |

*Last updated: October 13, 2026.*
