POST /v1/dataContracts
from metadata.sdk import configure
from metadata.sdk.entities import DataContracts
from metadata.generated.schema.api.data.createDataContract import (
CreateDataContractRequest,
)
configure(
host="https://your-company.open-metadata.org/api",
jwt_token="your-jwt-token"
)
request = CreateDataContractRequest.model_validate({
"name": "sales-orders-contract",
"entity": {"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "type": "table"},
"description": "Data contract for the sales orders table",
"entityStatus": "Approved",
"schema": [
{"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
],
"semantics": [
{
"name": "Owners is set",
"description": "The table must have an owner.",
"rule": '{"and":[{"some":[{"var":"owners"},{"!=":[{"var":"fullyQualifiedName"},null]}]}]}',
"enabled": True,
}
],
"sla": {"refreshFrequency": {"interval": 1, "unit": "day"}},
})
contract = DataContracts.create(request)
print(f"Created contract: {contract.fullyQualifiedName.root}")
import static org.openmetadata.sdk.fluent.DataContracts.*;
DataContract contract = create()
.name("sales-orders-contract")
.forEntity(new EntityReference()
.withId(tableId)
.withType("table"))
.withDescription("Data contract for the sales orders table")
.withStatus(EntityStatus.APPROVED)
.withSchema(List.of(
new Column().withName("order_id").withDataType(ColumnDataType.INT),
new Column().withName("order_date").withDataType(ColumnDataType.TIMESTAMP)
))
.withSemanticRule(new SemanticsRule()
.withName("Owners is set")
.withDescription("The table must have an owner.")
.withRule("{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}"))
.withSla(new ContractSLA()
.withRefreshFrequency(new RefreshFrequency()
.withInterval(1)
.withUnit(RefreshFrequency.Unit.DAY)))
.execute();
curl -X POST "{base_url}/api/v1/dataContracts" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"name": "sales-orders-contract",
"entity": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "table"
},
"description": "Data contract for the sales orders table",
"entityStatus": "Approved",
"schema": [
{"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"}
],
"semantics": [
{
"name": "Owners is set",
"description": "The table must have an owner.",
"rule": "{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}",
"enabled": true
}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "day"}
}
}'
{
"id": "f7a1b2c3-d4e5-6789-0abc-def123456789",
"name": "sales-orders-contract",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract",
"description": "Data contract for the sales orders table",
"entityStatus": "Approved",
"entity": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "table",
"name": "sales_orders",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders"
},
"schema": [
{"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"}
],
"semantics": [
{
"name": "Owners is set",
"description": "The table must have an owner.",
"rule": "{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}",
"enabled": true
}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "day"}
},
"version": 0.1,
"updatedAt": 1769982800000,
"updatedBy": "admin"
}
Create a Data Contract
Create a new data contract for a data asset
POST
/
v1
/
dataContracts
POST /v1/dataContracts
from metadata.sdk import configure
from metadata.sdk.entities import DataContracts
from metadata.generated.schema.api.data.createDataContract import (
CreateDataContractRequest,
)
configure(
host="https://your-company.open-metadata.org/api",
jwt_token="your-jwt-token"
)
request = CreateDataContractRequest.model_validate({
"name": "sales-orders-contract",
"entity": {"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "type": "table"},
"description": "Data contract for the sales orders table",
"entityStatus": "Approved",
"schema": [
{"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
],
"semantics": [
{
"name": "Owners is set",
"description": "The table must have an owner.",
"rule": '{"and":[{"some":[{"var":"owners"},{"!=":[{"var":"fullyQualifiedName"},null]}]}]}',
"enabled": True,
}
],
"sla": {"refreshFrequency": {"interval": 1, "unit": "day"}},
})
contract = DataContracts.create(request)
print(f"Created contract: {contract.fullyQualifiedName.root}")
import static org.openmetadata.sdk.fluent.DataContracts.*;
DataContract contract = create()
.name("sales-orders-contract")
.forEntity(new EntityReference()
.withId(tableId)
.withType("table"))
.withDescription("Data contract for the sales orders table")
.withStatus(EntityStatus.APPROVED)
.withSchema(List.of(
new Column().withName("order_id").withDataType(ColumnDataType.INT),
new Column().withName("order_date").withDataType(ColumnDataType.TIMESTAMP)
))
.withSemanticRule(new SemanticsRule()
.withName("Owners is set")
.withDescription("The table must have an owner.")
.withRule("{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}"))
.withSla(new ContractSLA()
.withRefreshFrequency(new RefreshFrequency()
.withInterval(1)
.withUnit(RefreshFrequency.Unit.DAY)))
.execute();
curl -X POST "{base_url}/api/v1/dataContracts" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"name": "sales-orders-contract",
"entity": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "table"
},
"description": "Data contract for the sales orders table",
"entityStatus": "Approved",
"schema": [
{"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"}
],
"semantics": [
{
"name": "Owners is set",
"description": "The table must have an owner.",
"rule": "{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}",
"enabled": true
}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "day"}
}
}'
{
"id": "f7a1b2c3-d4e5-6789-0abc-def123456789",
"name": "sales-orders-contract",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract",
"description": "Data contract for the sales orders table",
"entityStatus": "Approved",
"entity": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "table",
"name": "sales_orders",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders"
},
"schema": [
{"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"}
],
"semantics": [
{
"name": "Owners is set",
"description": "The table must have an owner.",
"rule": "{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}",
"enabled": true
}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "day"}
},
"version": 0.1,
"updatedAt": 1769982800000,
"updatedBy": "admin"
}
Create a Data Contract
Create a new data contract and attach it to a data asset. Only thename and entity reference are required — all other sections (schema, semantics, quality, SLA, security, terms of use) are optional.
Body Parameters
string
required
Name of the data contract, 1 to 256 characters. The contract’s fully qualified name is
<entityFQN>.dataContract_<name>.object
required
Reference to the data asset this contract applies to. An entity can have only one contract.
Show properties
Show properties
string
required
UUID of the entity.
string
required
Entity type. See Supported Entity Types.
string
Human-readable display name.
string
Description in Markdown format.
string
default:"Draft"
Contract status:
Draft, In Review, Approved, Rejected, Deprecated, or Archived.array
Expected columns or fields. Supported for
table, topic, apiEndpoint, and dashboardDataModel only. Each item follows the Column schema. Every name must exist on the entity, and no name can repeat.array
Semantics rules evaluated against the entity’s metadata when the contract is validated.
Show properties
Show properties
string
required
Rule name.
string
required
Rule description. Reported as the failure reason when the rule fails.
string
required
JSON Logic expression. The rule passes when it returns
true.boolean
default:"true"
Whether the rule is evaluated.
string
Apply the rule only to this entity type.
array
Entity types the rule skips.
array
object
Service level agreement expectations. Stored and shown on the contract, but not checked by validation runs.
Show properties
Show properties
object
interval (integer) and unit: hour, day, week, month, or year.object
value (integer) and unit: minute, hour, or day.string
Time of day the data should be available, for example
09:00.string
default:"GMT+00:00 (Europe/London)"
Timezone for
availabilityTime, in the form GMT+05:30 (Asia/Kolkata).object
period (integer) and unit: day, week, month, or year.string
Column that holds the data’s refresh time.
string
Terms of use in Markdown format. Describes allowed and disallowed uses and compliance requirements. Returned as
termsOfUse.content on the contract.object
Security and access expectations. Stored and shown on the contract, but not enforced.
array
Owner references (users or teams).
array
Reviewer references (users or teams). When set, only a reviewer can move the contract from
In Review to Approved or Rejected.string
Date and time from which this contract is effective. Informational only.
string
Date and time until which this contract is effective. Informational only.
string
Link to where the contract is maintained.
POST /v1/dataContracts
from metadata.sdk import configure
from metadata.sdk.entities import DataContracts
from metadata.generated.schema.api.data.createDataContract import (
CreateDataContractRequest,
)
configure(
host="https://your-company.open-metadata.org/api",
jwt_token="your-jwt-token"
)
request = CreateDataContractRequest.model_validate({
"name": "sales-orders-contract",
"entity": {"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "type": "table"},
"description": "Data contract for the sales orders table",
"entityStatus": "Approved",
"schema": [
{"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
],
"semantics": [
{
"name": "Owners is set",
"description": "The table must have an owner.",
"rule": '{"and":[{"some":[{"var":"owners"},{"!=":[{"var":"fullyQualifiedName"},null]}]}]}',
"enabled": True,
}
],
"sla": {"refreshFrequency": {"interval": 1, "unit": "day"}},
})
contract = DataContracts.create(request)
print(f"Created contract: {contract.fullyQualifiedName.root}")
import static org.openmetadata.sdk.fluent.DataContracts.*;
DataContract contract = create()
.name("sales-orders-contract")
.forEntity(new EntityReference()
.withId(tableId)
.withType("table"))
.withDescription("Data contract for the sales orders table")
.withStatus(EntityStatus.APPROVED)
.withSchema(List.of(
new Column().withName("order_id").withDataType(ColumnDataType.INT),
new Column().withName("order_date").withDataType(ColumnDataType.TIMESTAMP)
))
.withSemanticRule(new SemanticsRule()
.withName("Owners is set")
.withDescription("The table must have an owner.")
.withRule("{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}"))
.withSla(new ContractSLA()
.withRefreshFrequency(new RefreshFrequency()
.withInterval(1)
.withUnit(RefreshFrequency.Unit.DAY)))
.execute();
curl -X POST "{base_url}/api/v1/dataContracts" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"name": "sales-orders-contract",
"entity": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "table"
},
"description": "Data contract for the sales orders table",
"entityStatus": "Approved",
"schema": [
{"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"}
],
"semantics": [
{
"name": "Owners is set",
"description": "The table must have an owner.",
"rule": "{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}",
"enabled": true
}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "day"}
}
}'
{
"id": "f7a1b2c3-d4e5-6789-0abc-def123456789",
"name": "sales-orders-contract",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract",
"description": "Data contract for the sales orders table",
"entityStatus": "Approved",
"entity": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "table",
"name": "sales_orders",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders"
},
"schema": [
{"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"}
],
"semantics": [
{
"name": "Owners is set",
"description": "The table must have an owner.",
"rule": "{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}",
"enabled": true
}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "day"}
},
"version": 0.1,
"updatedAt": 1769982800000,
"updatedBy": "admin"
}
Upsert (Create or Update)
UsePUT /v1/dataContracts with the same body to create a new contract or update an existing one.
Error Handling
| Code | Error Type | Description |
|---|---|---|
400 | BAD_REQUEST | Invalid request body, an entity type or section the entity doesn’t support, schema columns the entity doesn’t have, or an entity that already has a contract |
401 | UNAUTHORIZED | Invalid or missing authentication token |
403 | FORBIDDEN | User lacks permission to create data contracts |
404 | NOT_FOUND | The referenced entity doesn’t exist |
Was this page helpful?