Apicurio Registry data contracts
This chapter introduces the Data Contracts framework in Apicurio Registry, which provides comprehensive support for managing schema contracts between data producers and consumers.
Overview
The Data Contracts framework enables teams to define, enforce, and track formal agreements about schema structure, ownership, and quality. Data contracts help ensure data producers and consumers adhere to clearly defined standards throughout the schema lifecycle.
A data contract in Apicurio Registry combines:
-
Metadata - Standardized ownership, classification, and support information
-
Lifecycle - Status tracking (DRAFT, STABLE, DEPRECATED) and promotion workflows
-
Field Tags - Semantic annotation of schema fields (for example, PII, SENSITIVE, EMAIL)
-
Rules - Governance rules (registry-side) and validation/transformation rules (runtime)
-
Migration - Schema evolution with data transformation between versions
Contract metadata
Contract metadata provides standardized information about schema ownership, classification, and support. Metadata is stored using the reserved contract.* label namespace.
Metadata fields
The following metadata fields are available for data contracts:
| Field | Type | Description |
|---|---|---|
|
Enum |
Contract lifecycle status: |
|
String |
Name of the team responsible for the contract |
|
String |
Business domain (for example, payments, orders, users) |
|
String |
Support email address |
|
Enum |
Data classification: |
|
Enum |
Promotion stage: |
|
ISO-8601 date |
Date when the contract status became STABLE |
|
ISO-8601 date |
Date when the contract status became DEPRECATED |
|
String |
Reason for deprecating the contract |
Data classification levels
Data classification helps teams understand the sensitivity of data in a contract:
-
PUBLIC - No restrictions, data can be freely shared
-
INTERNAL - For internal use only, not for external parties
-
CONFIDENTIAL - Need-to-know basis, limited access
-
RESTRICTED - Highly sensitive data requiring strict access controls
Contract lifecycle
The contract lifecycle tracks the maturity and availability of a schema through defined status transitions.
Lifecycle statuses
-
DRAFT - Initial state. The schema is being developed and is not ready for production use.
-
STABLE - The schema is production-ready and consumers can rely on it.
-
DEPRECATED - The schema is being phased out. Consumers should migrate to a newer version.
Status transitions
The following status transitions are allowed:
DRAFT ──────► STABLE ──────► DEPRECATED
│ ▲
└──────────────────────────────┘
(skip stable)
-
DRAFT→STABLE- Use when the schema is ready for production -
STABLE→DEPRECATED- Use when phasing out the schema -
DRAFT→DEPRECATED- Use to deprecate without ever reaching stable
Reverse transitions (for example, STABLE → DRAFT or DEPRECATED → STABLE) are not allowed.
|
Promotion workflow (planned)
| Automated promotion workflow enforcement is planned for a future release. The promotion stage label can be set manually. |
The promotion workflow tracks which environment a contract is deployed to:
DEV ──────► STAGE ──────► PROD
-
DEV - Development environment
-
STAGE - Staging or QA environment
-
PROD - Production environment
Promotion rules:
-
You can only promote to the next stage (DEV → STAGE → PROD)
-
You cannot skip stages (DEV → PROD is not allowed)
-
You cannot demote (PROD → STAGE is not allowed)
-
PROD promotion might require STABLE status (configurable)
Field-level tags (planned)
| Field-level tags are planned for a future release and are not yet implemented. |
Field tags provide semantic annotation of schema fields, enabling you to identify sensitive data, apply tag-based rules, and search for artifacts by tag.
Supported tag formats
Tags can be embedded directly in schema definitions:
{
"type": "record",
"name": "User",
"fields": [{
"name": "email",
"type": "string",
"tags": ["PII", "EMAIL"]
}, {
"name": "ssn",
"type": "string",
"tags": ["PII", "SENSITIVE"]
}]
}
{
"type": "object",
"properties": {
"email": {
"type": "string",
"x-tags": ["PII", "EMAIL"]
}
}
}
message User {
string email = 1 [(apicurio.field_meta).tags = "PII,EMAIL"];
}
Contract rules (planned)
| Contract rules are planned for a future release and are not yet implemented. |
Contract rules enable you to enforce governance policies and validate or transform data. Rules are organized into three categories based on when they execute.
Governance rules (registry-side)
Governance rules execute when artifacts are created or updated. They enforce policies at the registry level.
| Rule | Description |
|---|---|
|
Require the owner team to be set before registration |
|
Require data classification to be specified |
|
Block updates to contracts with DEPRECATED status |
|
Require STABLE status before promoting to PROD |
Validation rules (client-side)
Validation rules execute during serialization (WRITE) or deserialization (READ). They validate data against business rules using CEL (Common Expression Language).
{
"name": "validateAge",
"kind": "CONDITION",
"type": "CEL",
"mode": "WRITE",
"expr": "message.age >= 0 && message.age <= 150",
"onFailure": "ERROR"
}
Transform rules (client-side)
Transform rules modify data during serialization or deserialization.
{
"name": "encryptPII",
"kind": "TRANSFORM",
"type": "ENCRYPT",
"mode": "WRITE",
"tags": ["PII"],
"params": {
"encrypt.kek.name": "pii-key"
}
}
Schema migration rules (planned)
| Schema migration rules are planned for a future release and are not yet implemented. |
Migration rules enable schema evolution with data transformation between versions. When a consumer reads data written with an older schema version, migration rules transform the data to match the expected format.
Migration directions
-
UPGRADE - Transform data from an older schema version to a newer one
-
DOWNGRADE - Transform data from a newer schema version to an older one
JSONata transforms
Migration rules use JSONata expressions for data transformation:
{
"name": "upgradeToV2",
"kind": "TRANSFORM",
"type": "JSONATA",
"mode": "UPGRADE",
"expr": "{ 'fullName': firstName & ' ' & lastName }"
}
This rule transforms:
// Input (v1)
{ "firstName": "John", "lastName": "Doe" }
// Output (v2)
{ "fullName": "John Doe" }
REST API (planned)
| The Data Contracts REST API endpoints are planned for a future release and are not yet implemented. Contract metadata can currently be managed through the standard artifact/version labels API. |
The Data Contracts REST API provides endpoints for managing all aspects of contracts.
Contract endpoints
| Method | Endpoint | Description |
|---|---|---|
GET |
|
Get contract metadata, rules, and tags |
PUT |
|
Create or update contract |
DELETE |
|
Remove contract |
POST |
|
Change lifecycle status |
POST |
|
Promote to next stage |
GET |
|
Get field-level tags |
PUT |
|
Set external tags |
GET |
|
Get contract rules |
PUT |
|
Update contract rules |
POST |
|
Execute rules (for testing) |
GET |
|
Get quality score |
Example: Setting contract metadata
curl -X PUT \
http://localhost:8080/apis/registry/v3/groups/my-group/artifacts/my-artifact/contract \
-H 'Content-Type: application/json' \
-d '{
"status": "DRAFT",
"ownerTeam": "Platform Team",
"ownerDomain": "payments",
"supportContact": "platform@example.com",
"classification": "CONFIDENTIAL",
"stage": "DEV"
}'
Configuration
Configure the Data Contracts framework using Apicurio Registry application properties.
Configuration properties
| Property | Default | Description |
|---|---|---|
|
|
Enable or disable the data contracts feature (experimental) |
| The following configuration properties are planned for future releases and are not yet available. |
| Property | Default | Description |
|---|---|---|
|
|
Require owner team to be set |
|
|
Require data classification to be set |
|
|
Block updates to deprecated contracts |
|
|
Require STABLE status for PROD promotion |
|
|
Quality score cache TTL in seconds |
|
|
Stop on first rule failure |
|
|
Rule cache TTL in seconds |
SerDes configuration (planned)
| SerDes rule execution configuration is planned for a future release. |
Configure rule execution in Kafka serializers/deserializers:
| Property | Default | Description |
|---|---|---|
|
|
Enable rule execution in SerDes |
|
|
Action on rule failure: |
|
Dead letter queue topic name |
