POST /v1/dataContracts
from metadata.sdk import configure
from metadata.sdk.entities import DataContracts
configure(
host="https://your-company.getcollate.io/api",
jwt_token="your-jwt-token"
)
# Create a basic data contract for a table
contract = DataContracts.create(
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": "hasOwner"},
{"name": "hasDescription"},
{"name": "hasTags"}
],
sla={
"refreshFrequency": {"interval": 1, "unit": "hour"},
"availabilityTime": "09:00 UTC"
}
)
print(f"Created contract: {contract.fullyQualifiedName}")
import static org.openmetadata.sdk.fluent.DataContracts.*;
// client is an initialized OpenMetadataClient.
setDefaultClient(client);
// Create a data contract with fluent API
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("customer_id").withDataType(ColumnDataType.INT),
new Column().withName("order_date").withDataType(ColumnDataType.TIMESTAMP)
))
.withSemanticRule(new SemanticsRule().withName("hasOwner"))
.withSemanticRule(new SemanticsRule().withName("hasDescription"))
.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": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
{"name": "total_amount", "dataType": "DECIMAL"}
],
"semantics": [
{"name": "hasOwner"},
{"name": "hasDescription"},
{"name": "hasTags"}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "hour"},
"availabilityTime": "09:00 UTC"
}
}'
{
"id": "f7a1b2c3-d4e5-6789-0abc-def123456789",
"name": "sales-orders-contract",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract",
"displayName": "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": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
{"name": "total_amount", "dataType": "DECIMAL"}
],
"semantics": [
{"name": "hasOwner"},
{"name": "hasDescription"},
{"name": "hasTags"}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "hour"},
"availabilityTime": "09:00 UTC"
},
"version": 0.1,
"updatedAt": 1769982800000,
"updatedBy": "admin"
}
Create a Data Contract
Create a new data contract defining quality expectations, SLAs, schema requirements, and ownership agreements for a data asset using the Collate REST API.
POST
/
v1
/
dataContracts
POST /v1/dataContracts
from metadata.sdk import configure
from metadata.sdk.entities import DataContracts
configure(
host="https://your-company.getcollate.io/api",
jwt_token="your-jwt-token"
)
# Create a basic data contract for a table
contract = DataContracts.create(
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": "hasOwner"},
{"name": "hasDescription"},
{"name": "hasTags"}
],
sla={
"refreshFrequency": {"interval": 1, "unit": "hour"},
"availabilityTime": "09:00 UTC"
}
)
print(f"Created contract: {contract.fullyQualifiedName}")
import static org.openmetadata.sdk.fluent.DataContracts.*;
// client is an initialized OpenMetadataClient.
setDefaultClient(client);
// Create a data contract with fluent API
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("customer_id").withDataType(ColumnDataType.INT),
new Column().withName("order_date").withDataType(ColumnDataType.TIMESTAMP)
))
.withSemanticRule(new SemanticsRule().withName("hasOwner"))
.withSemanticRule(new SemanticsRule().withName("hasDescription"))
.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": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
{"name": "total_amount", "dataType": "DECIMAL"}
],
"semantics": [
{"name": "hasOwner"},
{"name": "hasDescription"},
{"name": "hasTags"}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "hour"},
"availabilityTime": "09:00 UTC"
}
}'
{
"id": "f7a1b2c3-d4e5-6789-0abc-def123456789",
"name": "sales-orders-contract",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract",
"displayName": "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": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
{"name": "total_amount", "dataType": "DECIMAL"}
],
"semantics": [
{"name": "hasOwner"},
{"name": "hasDescription"},
{"name": "hasTags"}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "hour"},
"availabilityTime": "09:00 UTC"
},
"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. Must be unique.
object
required
Reference to the data asset this contract applies to.
string
Human-readable display name.
string
Description in Markdown format.
string
default:"Draft"
Contract status:
Draft, In Review, Approved, Rejected, Deprecated, or Archived.array
array
array
object
Service level agreement expectations.
Show properties
Show properties
object
object
string
Time of day by which data is expected to be available (for example,
09:00 UTC).string
Time zone for the availability time. Defaults to UTC.
string
Terms of use in Markdown format. Describes allowed/disallowed use cases and compliance requirements.
object
array
Owner references (users or teams).
array
Reviewer user references.
string
ISO 8601 date from which this contract is effective.
string
ISO 8601 date until which this contract is effective.
POST /v1/dataContracts
from metadata.sdk import configure
from metadata.sdk.entities import DataContracts
configure(
host="https://your-company.getcollate.io/api",
jwt_token="your-jwt-token"
)
# Create a basic data contract for a table
contract = DataContracts.create(
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": "hasOwner"},
{"name": "hasDescription"},
{"name": "hasTags"}
],
sla={
"refreshFrequency": {"interval": 1, "unit": "hour"},
"availabilityTime": "09:00 UTC"
}
)
print(f"Created contract: {contract.fullyQualifiedName}")
import static org.openmetadata.sdk.fluent.DataContracts.*;
// client is an initialized OpenMetadataClient.
setDefaultClient(client);
// Create a data contract with fluent API
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("customer_id").withDataType(ColumnDataType.INT),
new Column().withName("order_date").withDataType(ColumnDataType.TIMESTAMP)
))
.withSemanticRule(new SemanticsRule().withName("hasOwner"))
.withSemanticRule(new SemanticsRule().withName("hasDescription"))
.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": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
{"name": "total_amount", "dataType": "DECIMAL"}
],
"semantics": [
{"name": "hasOwner"},
{"name": "hasDescription"},
{"name": "hasTags"}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "hour"},
"availabilityTime": "09:00 UTC"
}
}'
{
"id": "f7a1b2c3-d4e5-6789-0abc-def123456789",
"name": "sales-orders-contract",
"fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract",
"displayName": "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": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"},
{"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"},
{"name": "total_amount", "dataType": "DECIMAL"}
],
"semantics": [
{"name": "hasOwner"},
{"name": "hasDescription"},
{"name": "hasTags"}
],
"sla": {
"refreshFrequency": {"interval": 1, "unit": "hour"},
"availabilityTime": "09:00 UTC"
},
"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 or missing required fields |
401 | UNAUTHORIZED | Invalid or missing authentication token |
403 | FORBIDDEN | User lacks permission to create data contracts |
409 | CONFLICT | A contract with the same name already exists |
Was this page helpful?