Skip to content

Distinct Count Check API

This page documents how to create and manage a Distinct Count check via the REST API. The check uses the standard Quality Checks endpoints: set rule to distinctCount, list exactly one field under fields, and provide the operator and the expected number under properties. 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.

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 for the full matrix.

The properties object

Distinct Count carries its rule-specific configuration under properties:

Field Required Type Description
comparison Yes string The operator applied between the measured count and value: lt, lte, eq, gte, or gt.
value Yes number The expected number of distinct values.

Create

Endpoint: POST /api/quality-checks

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

Create a Distinct Count check (every accepted field)
curl -X POST "https://your-instance.qualytics.io/api/quality-checks" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
      "description": "The order status column must hold exactly 3 distinct values.",
      "rule": "distinctCount",
      "fields": ["o_orderstatus"],
      "container_id": 145,
      "filter": null,
      "properties": {"comparison": "eq", "value": 3},
      "tags": ["reference-data", "cardinality"],
      "additional_metadata": {"jira": "DATA-9701"},
      "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 "distinctCount".
fields Yes Array with exactly one entry. Every field type is accepted.
container_id Yes ID of the container (table or file) the check runs against.
filter No SQL WHERE expression. Applied before the evaluation, so only filtered rows are evaluated. Send null for no filter.
properties Yes Object holding the operator and the expected count. See above.
tags No List of tag names applied to the check for filtering and organization.
additional_metadata No Free-form key-value pairs (typically links to catalog entries, tickets, governance records).
template_id No ID of a Check Template to associate the check with. null if not using a template.
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 asserts one number about the dataset, so there is no per-row violation rate. Omit it, or send 1 for backward compatibility; any other value is rejected with 422 Unprocessable Entity.
  • anomaly_message_field is ignored. Distinct Count 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.

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

Update

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

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

The PUT endpoint requires description; include the check's current description (or a new one) along with the fields you want to change. Send the whole properties object: partial property updates are not merged.

Loosen the comparison on an existing check
curl -X PUT "https://your-instance.qualytics.io/api/quality-checks/101" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "The order status column must hold at least 3 distinct values.",
    "properties": {"comparison": "gte", "value": 3}
  }'

A PUT can update most fields on an existing Distinct Count check. Three values stay immutable: the rule type, the container the check is attached to, and the associated Check Template. If any of these needs to change, delete the check and create a new one.

Editable vs Immutable on PUT

Editable

  • description
  • filter
  • properties.comparison and properties.value
  • tags
  • additional_metadata
  • fields (must remain a single field)
  • 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.
Archive a check, keeping its anomalies
curl -X DELETE "https://your-instance.qualytics.io/api/quality-checks/101?archive=true&status=Discarded&delete_anomalies=false" \
  -H "Authorization: Bearer YOUR_TOKEN"
Delete a check permanently
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.
422 Unprocessable Entity The payload fails schema validation (for example, description missing on PUT, or properties.comparison is missing or is not one of the accepted operators).