Skip to main content
POST
https://sandbox.getcollate.io/api
/
v1
/
dataQuality
/
testDefinitions
POST /v1/dataQuality/testDefinitions
from metadata.sdk import configure
from metadata.sdk.entities import TestDefinitions
from metadata.generated.schema.api.tests.createTestDefinition import CreateTestDefinitionRequest

configure(
    host="https://your-company.getcollate.io/api",
    jwt_token="your-jwt-token"
)

request = CreateTestDefinitionRequest(
    name="columnValuesToMatchBusinessRule",
    displayName="Column Values To Match Business Rule",
    description="Validates that column values conform to a custom business rule regex pattern",
    entityType="COLUMN",
    testPlatforms=["OpenMetadata"],
    supportedDataTypes=["STRING", "VARCHAR", "TEXT"],
    parameterDefinition=[
        {
            "name": "regexPattern",
            "dataType": "STRING",
            "required": True,
            "description": "The regex pattern to match against"
        },
        {
            "name": "threshold",
            "dataType": "INT",
            "required": False,
            "description": "Maximum number of non-matching values allowed"
        }
    ]
)

test_def = TestDefinitions.create(request)
print(f"Created: {test_def.name}")
{
  "id": "b7c4e912-3a1f-4d6e-9c2b-8f5a7d3e1b4c",
  "name": "columnValuesToMatchBusinessRule",
  "displayName": "Column Values To Match Business Rule",
  "fullyQualifiedName": "columnValuesToMatchBusinessRule",
  "description": "Validates that column values conform to a custom business rule regex pattern",
  "version": 0.1,
  "updatedAt": 1769982700000,
  "updatedBy": "admin",
  "testPlatforms": ["OpenMetadata"],
  "supportedDataTypes": ["STRING", "VARCHAR", "TEXT"],
  "parameterDefinition": [
    {
      "name": "regexPattern",
      "dataType": "STRING",
      "required": true,
      "description": "The regex pattern to match against"
    },
    {
      "name": "threshold",
      "dataType": "INT",
      "required": false,
      "description": "Maximum number of non-matching values allowed"
    }
  ],
  "entityType": "COLUMN",
  "provider": "user",
  "deleted": false
}

Create a Test Definition

Create a custom test definition to define organization-specific data quality validation logic.

Body Parameters

name
string
required
Name of the test definition. Must be unique across all test definitions.
displayName
string
Human-readable display name for the test definition.
description
string
Description of what this test validates, in Markdown format.
entityType
string
required
The entity type this test targets: TABLE or COLUMN.
testPlatforms
array
required
Array of supported test platforms. Typically ["OpenMetadata"].
supportedDataTypes
array
Array of data types this test can be applied to (e.g., STRING, INT, DOUBLE, VARCHAR, CHAR, TEXT, NUMBER, FLOAT, BOOLEAN). Only applicable when entityType is COLUMN.
parameterDefinition
array
Array of parameter definitions that this test accepts.
owners
array
Array of owner references (users or teams) to assign.
POST /v1/dataQuality/testDefinitions
from metadata.sdk import configure
from metadata.sdk.entities import TestDefinitions
from metadata.generated.schema.api.tests.createTestDefinition import CreateTestDefinitionRequest

configure(
    host="https://your-company.getcollate.io/api",
    jwt_token="your-jwt-token"
)

request = CreateTestDefinitionRequest(
    name="columnValuesToMatchBusinessRule",
    displayName="Column Values To Match Business Rule",
    description="Validates that column values conform to a custom business rule regex pattern",
    entityType="COLUMN",
    testPlatforms=["OpenMetadata"],
    supportedDataTypes=["STRING", "VARCHAR", "TEXT"],
    parameterDefinition=[
        {
            "name": "regexPattern",
            "dataType": "STRING",
            "required": True,
            "description": "The regex pattern to match against"
        },
        {
            "name": "threshold",
            "dataType": "INT",
            "required": False,
            "description": "Maximum number of non-matching values allowed"
        }
    ]
)

test_def = TestDefinitions.create(request)
print(f"Created: {test_def.name}")
{
  "id": "b7c4e912-3a1f-4d6e-9c2b-8f5a7d3e1b4c",
  "name": "columnValuesToMatchBusinessRule",
  "displayName": "Column Values To Match Business Rule",
  "fullyQualifiedName": "columnValuesToMatchBusinessRule",
  "description": "Validates that column values conform to a custom business rule regex pattern",
  "version": 0.1,
  "updatedAt": 1769982700000,
  "updatedBy": "admin",
  "testPlatforms": ["OpenMetadata"],
  "supportedDataTypes": ["STRING", "VARCHAR", "TEXT"],
  "parameterDefinition": [
    {
      "name": "regexPattern",
      "dataType": "STRING",
      "required": true,
      "description": "The regex pattern to match against"
    },
    {
      "name": "threshold",
      "dataType": "INT",
      "required": false,
      "description": "Maximum number of non-matching values allowed"
    }
  ],
  "entityType": "COLUMN",
  "provider": "user",
  "deleted": false
}

Returns

Returns the created test definition object with all specified properties and system-generated fields.

Response

id
string
Unique identifier for the test definition (UUID format).
name
string
Test definition name.
fullyQualifiedName
string
Fully qualified name (same as name for test definitions).
displayName
string
Human-readable display name.
description
string
Description of what the test validates.
entityType
string
Target entity type: TABLE or COLUMN.
testPlatforms
array
Supported test platforms.
supportedDataTypes
array
Data types this test can be applied to.
parameterDefinition
array
Parameters accepted by this test definition.
provider
string
Always user for custom test definitions.
version
number
Version number for the entity (starts at 0.1).

Create or Update (PUT)

Use PUT /v1/dataQuality/testDefinitions instead of POST to perform an upsert. If a test definition with the same name already exists, it will be updated; otherwise, a new test definition is created. The request body is the same as POST.
curl -X PUT "{base_url}/api/v1/dataQuality/testDefinitions" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{ ... same body as POST ... }'
PUT will not return a 409 conflict error if the entity already exists — it will update the existing entity instead.

Error Handling

CodeError TypeDescription
400BAD_REQUESTInvalid request body or missing required fields
401UNAUTHORIZEDInvalid or missing authentication token
403FORBIDDENUser lacks permission to create test definitions
409ENTITY_ALREADY_EXISTSTest definition with same name already exists (POST only)