Skip to content

Templates API

Check templates are managed through the same API as checks. A template is returned in the same shape as a check, without a table or fields. Every endpoint below requires the Manager or Admin role, except listing templates and creating a single check from one. For interactive request and response schemas, open /api/docs on your deployment.

Endpoints

Method Endpoint What it does
GET /api/quality-checks?template_only=true Lists check templates. Add template_locked=true or false to list only locked or unlocked ones.
GET /api/quality-checks/{id} Returns one template by its id.
POST /api/quality-check-templates Creates a template.
PUT /api/quality-check-templates/{id} Updates a template. On a locked template, the change also reaches its linked checks.
PATCH /api/quality-check-templates Updates several templates at once. See Bulk Edit Templates.
DELETE /api/quality-check-templates/{id} Archives a template and unlinks its checks. A template is never deleted permanently.
DELETE /api/quality-check-templates Archives several templates, sent as a list of entries with each template's id.
POST /api/quality-checks/{id}/template Creates an unlocked template from the check {id} and links the check to it.
POST /api/quality-checks Creates one check. Send template_id to create it from a template. This follows the check's team permissions, not the Manager role.
POST /api/quality-check-templates/{id}/bulk-create Creates one check per entry from the template {id}, as Draft.
POST /api/quality-check-templates/{id}/bulk-validate Validates the same entries as bulk-create without creating anything.

Create a Template

POST /api/quality-check-templates takes the template's definition:

Field Required Description
rule The rule type, such as notNull. It cannot be changed later.
description The description the checks start with.
template_locked true to keep the linked checks in sync with the template. Defaults to false.
filter The filter clause. It can use each(). See Filter Permutations.
coverage The coverage, from 0 to 1.
properties The rule type's properties, the same as on that rule type's API page.
tags The tag names.
additional_metadata Key-value metadata.
Create a locked Not Null template
{
  "rule": "notNull",
  "description": "Every customer record must carry a customer ID",
  "template_locked": true,
  "filter": "is_test = false",
  "coverage": 1,
  "tags": ["customer-data"]
}

PUT /api/quality-check-templates/{id} takes the same fields, minus rule. Fields you leave out keep their value.

Create Checks from a Template

POST /api/quality-check-templates/{id}/bulk-create takes a list, one entry per check:

Field Required Description
container_id The table or file that will hold the check.
description The check's description.
fields The field names the check applies to, when the rule type takes fields.
filter A filter clause for this check.
coverage The coverage, from 0 to 1.
owner_id The user who owns the check.
default_anomaly_assignee_id The user assigned to the check's anomalies.
tags The check's tags.
Apply a template to two tables
[
  {"container_id": 101, "fields": ["customer_id"], "description": "Every customer record must carry a customer ID"},
  {"container_id": 202, "fields": ["cust_id"], "description": "Every customer record must carry a customer ID"}
]

Send the same list to bulk-validate first to catch problems without creating anything. Creating the checks also needs the Drafter team permission on each target datastore.

Errors

Status When
403 Your role is below Manager, or a template edit would reach linked checks in datastores you cannot access.
406 Archiving a locked template that still has linked checks, or creating a template from a check that is already a template.
409 Creating a template from a check that is already linked to a template, or creating each() permutations a table already has.

Export

Templates can also be written to an enrichment datastore with a Global Export operation. See Export Templates.