Data Quality

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

GET
POST
GET
PATCH
DELETE
POST
GET
GET
GET
GET
GET
GET
PATCH
GET
GET

List all data quality checks

Every check in the project. Narrow it to one subject with subject_type and subject_uuid, or to one assertion with check_type.

Required API key scopes

query:read

Query parameters

  • check_type
    string
    One of: "accepted_values""custom_sql""freshness""not_null""relationships""row_count""unique"
  • limit
    integer
  • offset
    integer
  • subject_type
    string
    One of: "metric""posthog_table""table""view"
  • subject_uuid
    string

Response


Example request

GET /api/projects/:project_id/data_quality_checks
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"subject_type": "table",
"subject_uuid": "f50d0d7b-008d-4d86-9bfa-ff1551adaedc",
"subject_name": "string",
"subject_status": "string",
"column_name": "string",
"check_type": "not_null",
"config": {},
"severity": "error",
"enabled": true,
"tags": [
"string"
],
"owner": "string",
"last_run_at": "2019-08-24T14:15:22Z",
"last_status": "string",
"last_succeeded_at": "2019-08-24T14:15:22Z",
"failing_since": "2019-08-24T14:15:22Z",
"fingerprint": "string",
"created_source": "user",
"ai_model": "string",
"confidence": 1,
"reasoning": "string",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"subject_node_id": "d2487b5d-e335-4eb6-864b-efacbfbf8937",
"subject_source_id": "e73bea0e-332b-4501-b025-578fa8bb608b",
"subject_schema_id": "7add8d9b-16c5-4387-97c4-8345f19bf24f",
"subject_metric_name": "string"
}
]
}

Create data quality checks

Create a check on the table, view or metric named by subject_type and subject_uuid, or refine the one already carrying the same fingerprint. Re-creating a semantically identical check returns 200 and the existing row, never a duplicate.

Required API key scopes

query:read

Request parameters

  • name
  • description
    string
  • subject_type
  • subject_uuid
    string
  • column_name
    string
  • check_type
  • config
    object
  • severity
  • enabled
    boolean
  • tags
    array
  • created_source
  • ai_model
    string
  • confidence
    number | null
  • reasoning
    string

Response


Example request

POST /api/projects/:project_id/data_quality_checks
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/\
-d subject_type=undefined,\
-d subject_uuid="string",\
-d check_type=undefined

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"subject_type": "table",
"subject_uuid": "f50d0d7b-008d-4d86-9bfa-ff1551adaedc",
"subject_name": "string",
"subject_status": "string",
"column_name": "string",
"check_type": "not_null",
"config": {},
"severity": "error",
"enabled": true,
"tags": [
"string"
],
"owner": "string",
"last_run_at": "2019-08-24T14:15:22Z",
"last_status": "string",
"last_succeeded_at": "2019-08-24T14:15:22Z",
"failing_since": "2019-08-24T14:15:22Z",
"fingerprint": "string",
"created_source": "user",
"ai_model": "string",
"confidence": 1,
"reasoning": "string",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Retrieve data quality checks

Every check in the project: authoring, running, results, health, and schedules.

Required API key scopes

query:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/data_quality_checks/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"subject_type": "table",
"subject_uuid": "f50d0d7b-008d-4d86-9bfa-ff1551adaedc",
"subject_name": "string",
"subject_status": "string",
"column_name": "string",
"check_type": "not_null",
"config": {},
"severity": "error",
"enabled": true,
"tags": [
"string"
],
"owner": "string",
"last_run_at": "2019-08-24T14:15:22Z",
"last_status": "string",
"last_succeeded_at": "2019-08-24T14:15:22Z",
"failing_since": "2019-08-24T14:15:22Z",
"fingerprint": "string",
"created_source": "user",
"ai_model": "string",
"confidence": 1,
"reasoning": "string",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Update data quality checks

Edit this check in place, including what it asserts (check_type, column_name, config). The subject it audits is fixed, and the check keeps its id, run history, latest status, and latest run time. A definition or name already held by another active check comes back as a field error, with nothing written.

Required API key scopes

query:read

Path parameters

  • id
    string

Request parameters

  • name
  • description
    string
  • column_name
    string
  • check_type
  • config
    object
  • severity
  • enabled
    boolean
  • tags
    array
  • created_source
  • ai_model
    string
  • confidence
    number | null
  • reasoning
    string

Response


Example request

PATCH /api/projects/:project_id/data_quality_checks/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/:id/\
-d name=undefined

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"subject_type": "table",
"subject_uuid": "f50d0d7b-008d-4d86-9bfa-ff1551adaedc",
"subject_name": "string",
"subject_status": "string",
"column_name": "string",
"check_type": "not_null",
"config": {},
"severity": "error",
"enabled": true,
"tags": [
"string"
],
"owner": "string",
"last_run_at": "2019-08-24T14:15:22Z",
"last_status": "string",
"last_succeeded_at": "2019-08-24T14:15:22Z",
"failing_since": "2019-08-24T14:15:22Z",
"fingerprint": "string",
"created_source": "user",
"ai_model": "string",
"confidence": 1,
"reasoning": "string",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Delete data quality checks

Every check in the project: authoring, running, results, health, and schedules.

Required API key scopes

query:read

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/data_quality_checks/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/:id/

Example response

Status 204 No response body

Create data quality checks run

Run this check now. Returns the suite run to poll for the report.

Required API key scopes

query:read

Path parameters

  • id
    string

Response


Example request

POST /api/projects/:project_id/data_quality_checks/:id/run
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/:id/run/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"trigger": "string",
"status": "string",
"subject_type": "string",
"subject_uuid": "f50d0d7b-008d-4d86-9bfa-ff1551adaedc",
"workflow_id": "string",
"checks_passed": 0,
"checks_failed": 0,
"checks_errored": 0,
"checks_skipped": 0,
"started_at": "2019-08-24T14:15:22Z",
"finished_at": "2019-08-24T14:15:22Z",
"error": "string",
"created_at": "2019-08-24T14:15:22Z"
}

List all data quality checks runs

Recent run history for this check, newest first.

Required API key scopes

query:read

Path parameters

  • id
    string

Example request

GET /api/projects/:project_id/data_quality_checks/:id/runs
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/:id/runs/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"quality_check": "5b7c54ee-fd30-47a5-9145-e51595a4799c",
"check_name": "string",
"suite_run": "055b78d3-f06e-47d5-aea7-eaaaeb0ef818",
"subject_type": "table",
"subject_uuid": "f50d0d7b-008d-4d86-9bfa-ff1551adaedc",
"subject_name": "string",
"check_type": "not_null",
"column_name": "string",
"check_config": {},
"check_severity": "error",
"status": "string",
"failed_row_count": 0,
"observed_value": 0,
"compiled_query": "string",
"audited_staged_refresh": true,
"error": "string",
"duration_ms": 0,
"started_at": "2019-08-24T14:15:22Z",
"finished_at": "2019-08-24T14:15:22Z",
"created_at": "2019-08-24T14:15:22Z"
}

List all data quality checks check types

The check types this project can author, with the JSON schema of each type's config. Pass subject_type to narrow it to the types that kind of subject supports.

Required API key scopes

query:read

Query parameters

  • subject_type
    string
    One of: "metric""posthog_table""table""view"

Example request

GET /api/projects/:project_id/data_quality_checks/check_types
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/check_types/

Example response

Status 200
RESPONSE
{
"check_type": "string",
"description": "string",
"requires_column": true,
"config_schema": {}
}

List all data quality checks health

Health rollup per subject, for every subject in the project that has checks. Narrow it to one subject with subject_type and subject_uuid.

Required API key scopes

query:read

Query parameters

  • subject_type
    string
    One of: "metric""posthog_table""table""view"
  • subject_uuid
    string

Example request

GET /api/projects/:project_id/data_quality_checks/health
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/health/

Example response

Status 200
RESPONSE
{
"subject_type": "string",
"subject_uuid": "string",
"health": "string",
"checks_total": 0,
"checks_failing": 0
}

List all data quality checks metric subjects

Every check in the project: authoring, running, results, health, and schedules.

Required API key scopes

data_catalog:readquery:read

Example request

GET /api/projects/:project_id/data_quality_checks/metric_subjects
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/metric_subjects/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"display_name": "string"
}

Retrieve data quality checks output schema

Columns the subject's query returns, for authoring a check against them. Metrics only.

Required API key scopes

query:read

Query parameters

  • subject_type
    string
    One of: "metric""posthog_table""table""view"
  • subject_uuid
    string

Response


Example request

GET /api/projects/:project_id/data_quality_checks/output_schema
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/output_schema/

Example response

Status 200
RESPONSE
{
"columns": [
{
"name": "string",
"type": "string"
}
]
}

Retrieve data quality checks schedule

The schedule every enabled check on this subject runs on.

Required API key scopes

query:read

Query parameters

  • subject_type
    string
    One of: "metric""posthog_table""table""view"
  • subject_uuid
    string

Response


Example request

GET /api/projects/:project_id/data_quality_checks/schedule
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/schedule/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"interval": "1hour",
"enabled": true,
"next_run_at": "2019-08-24T14:15:22Z",
"last_run_at": "2019-08-24T14:15:22Z",
"last_suite_run": "4a6dc5e1-02cf-442e-b4b0-1f8fdc70a528"
}

Update data quality checks schedule

Change how often this subject's checks run, or stop running them automatically. Name the subject with subject_type and subject_uuid in the body.

Required API key scopes

query:read

Request parameters

  • subject_type
  • subject_uuid
    string
  • interval
  • enabled
    boolean

Response


Example request

PATCH /api/projects/:project_id/data_quality_checks/schedule
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/schedule/\
-d subject_type=undefined

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"interval": "1hour",
"enabled": true,
"next_run_at": "2019-08-24T14:15:22Z",
"last_run_at": "2019-08-24T14:15:22Z",
"last_suite_run": "4a6dc5e1-02cf-442e-b4b0-1f8fdc70a528"
}

List all data quality checks schedules

The schedule of every subject in the project whose checks run on one, for the checks the caller may read. One request for the overview instead of one per subject.

Required API key scopes

query:read

Example request

GET /api/projects/:project_id/data_quality_checks/schedules
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/schedules/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"interval": "1hour",
"enabled": true,
"next_run_at": "2019-08-24T14:15:22Z",
"last_run_at": "2019-08-24T14:15:22Z",
"last_suite_run": "4a6dc5e1-02cf-442e-b4b0-1f8fdc70a528",
"subject_type": "table",
"subject_uuid": "f50d0d7b-008d-4d86-9bfa-ff1551adaedc"
}

List all data quality checks subjects

Everything in this project you can author a check on, with each subject's columns.

Required API key scopes

query:read

Example request

GET /api/projects/:project_id/data_quality_checks/subjects
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/data_quality_checks/subjects/

Example response

Status 200
RESPONSE
{
"subject_type": "table",
"id": "string",
"name": "string",
"display_name": "string",
"time_column": "string",
"columns": {
"property1": "string",
"property2": "string"
},
"editable": true
}