PUT /v1/dataContracts
curl -X PUT "{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": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
{"name": "total_amount", "dataType": "DECIMAL"}
],
"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"}
}
}'
from metadata.sdk import configure
from metadata.sdk.entities import DataContracts
configure(
host="https://your-company.open-metadata.org/api",
jwt_token="your-jwt-token"
)
# Update contract description and status
contract = DataContracts.retrieve("f7a1b2c3-d4e5-6789-0abc-def123456789")
contract.description = "Updated contract for sales orders table"
contract.entityStatus = "Approved"
contract = DataContracts.update(contract)
import static org.openmetadata.sdk.fluent.DataContracts.*;
// Update using fluent API
FluentDataContract contract = find(contractId).fetch();
contract.withDescription("Updated contract for sales orders table")
.withStatus(EntityStatus.APPROVED)
.save();
# Update description
curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json-patch+json" \
-d '[
{"op": "replace", "path": "/description", "value": "Updated contract for sales orders table"},
{"op": "replace", "path": "/entityStatus", "value": "Approved"}
]'
# Add a semantic rule
curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json-patch+json" \
-d '[
{"op": "add", "path": "/semantics/-", "value": {"name": "hasDomain"}}
]'
{
"id": "f7a1b2c3-d4e5-6789-0abc-def123456789",
"name": "sales-orders-contract",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract",
"description": "Updated contract for 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"
},
"version": 0.2,
"updatedAt": 1769986400000,
"updatedBy": "admin",
"changeDescription": {
"fieldsUpdated": [
{"name": "description", "oldValue": "Data contract for the sales orders table", "newValue": "Updated contract for sales orders table"},
{"name": "entityStatus", "oldValue": "Draft", "newValue": "Approved"}
]
}
}
Update a Data Contract
Create or update a data contract with a full request body
PUT
/
v1
/
dataContracts
PUT /v1/dataContracts
curl -X PUT "{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": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
{"name": "total_amount", "dataType": "DECIMAL"}
],
"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"}
}
}'
from metadata.sdk import configure
from metadata.sdk.entities import DataContracts
configure(
host="https://your-company.open-metadata.org/api",
jwt_token="your-jwt-token"
)
# Update contract description and status
contract = DataContracts.retrieve("f7a1b2c3-d4e5-6789-0abc-def123456789")
contract.description = "Updated contract for sales orders table"
contract.entityStatus = "Approved"
contract = DataContracts.update(contract)
import static org.openmetadata.sdk.fluent.DataContracts.*;
// Update using fluent API
FluentDataContract contract = find(contractId).fetch();
contract.withDescription("Updated contract for sales orders table")
.withStatus(EntityStatus.APPROVED)
.save();
# Update description
curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json-patch+json" \
-d '[
{"op": "replace", "path": "/description", "value": "Updated contract for sales orders table"},
{"op": "replace", "path": "/entityStatus", "value": "Approved"}
]'
# Add a semantic rule
curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json-patch+json" \
-d '[
{"op": "add", "path": "/semantics/-", "value": {"name": "hasDomain"}}
]'
{
"id": "f7a1b2c3-d4e5-6789-0abc-def123456789",
"name": "sales-orders-contract",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract",
"description": "Updated contract for 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"
},
"version": 0.2,
"updatedAt": 1769986400000,
"updatedBy": "admin",
"changeDescription": {
"fieldsUpdated": [
{"name": "description", "oldValue": "Data contract for the sales orders table", "newValue": "Updated contract for sales orders table"},
{"name": "entityStatus", "oldValue": "Draft", "newValue": "Approved"}
]
}
}
Update a Data Contract
Create a data contract or update it if it already exists, usingPUT /v1/dataContracts with the full request body. Send the complete definition, not just the fields you want to change. To change only some fields, use PATCH with a JSON Patch array and the application/json-patch+json content type, as shown in the PATCH examples below.
Body Parameters
Reference to the data asset this contract applies to.
Contract status:
Draft, In Review, Approved, Rejected, Deprecated, or Archived.Semantics rules evaluated against the entity’s metadata when the contract is validated.
Show properties
Show properties
JSON Logic expression. The rule passes when it returns
true.Service level agreement expectations. Stored and shown on the contract.
Show properties
Show properties
Timezone for
availabilityTime, in the form GMT+05:30 (Asia/Kolkata).Terms of use in Markdown format. Describes allowed/disallowed use cases and compliance requirements.
Security and access expectations. Stored and shown on the contract, but not enforced.
PUT /v1/dataContracts
curl -X PUT "{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": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
{"name": "total_amount", "dataType": "DECIMAL"}
],
"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"}
}
}'
from metadata.sdk import configure
from metadata.sdk.entities import DataContracts
configure(
host="https://your-company.open-metadata.org/api",
jwt_token="your-jwt-token"
)
# Update contract description and status
contract = DataContracts.retrieve("f7a1b2c3-d4e5-6789-0abc-def123456789")
contract.description = "Updated contract for sales orders table"
contract.entityStatus = "Approved"
contract = DataContracts.update(contract)
import static org.openmetadata.sdk.fluent.DataContracts.*;
// Update using fluent API
FluentDataContract contract = find(contractId).fetch();
contract.withDescription("Updated contract for sales orders table")
.withStatus(EntityStatus.APPROVED)
.save();
# Update description
curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json-patch+json" \
-d '[
{"op": "replace", "path": "/description", "value": "Updated contract for sales orders table"},
{"op": "replace", "path": "/entityStatus", "value": "Approved"}
]'
# Add a semantic rule
curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json-patch+json" \
-d '[
{"op": "add", "path": "/semantics/-", "value": {"name": "hasDomain"}}
]'
{
"id": "f7a1b2c3-d4e5-6789-0abc-def123456789",
"name": "sales-orders-contract",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract",
"description": "Updated contract for 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"
},
"version": 0.2,
"updatedAt": 1769986400000,
"updatedBy": "admin",
"changeDescription": {
"fieldsUpdated": [
{"name": "description", "oldValue": "Data contract for the sales orders table", "newValue": "Updated contract for sales orders table"},
{"name": "entityStatus", "oldValue": "Draft", "newValue": "Approved"}
]
}
}
Common Patch Operations
| Operation | Path | Description |
|---|---|---|
replace | /description | Update description |
replace | /entityStatus | Change status (Draft, In Review, Approved, Rejected, Deprecated, Archived) |
add | /semantics/- | Add a semantic rule |
remove | /semantics/0 | Remove a semantic rule by index |
replace | /sla | Update SLA section |
add | /schema/- | Add a schema column |
Error Handling
| Code | Error Type | Description |
|---|---|---|
400 | BAD_REQUEST | Invalid or malformed request body |
401 | UNAUTHORIZED | Invalid or missing authentication token |
403 | FORBIDDEN | User lacks permission to update data contracts |
Was this page helpful?