import static org.openmetadata.sdk.fluent.DataContracts.*;// client is an initialized OpenMetadataClient.setDefaultClient(client);// Create a data contract with fluent APIDataContract 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();
Create a new data contract defining quality expectations, SLAs, schema requirements, and ownership agreements for a data asset using the Collate REST API.
import static org.openmetadata.sdk.fluent.DataContracts.*;// client is an initialized OpenMetadataClient.setDefaultClient(client);// Create a data contract with fluent APIDataContract 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();
Create a new data contract and attach it to a data asset. Only the name 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.
The server stores the entity’s own name and fully qualified name in the reference, so responses and change events carry them. Send id and type. A name or fullyQualifiedName that doesn’t belong to the entity with that id returns 400.
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 column definitions. Each item follows the Column schema.
Show properties
string
required
Column name.
string
required
Data type (e.g., INT, VARCHAR, TIMESTAMP).
string
Constraint: NULL, NOT_NULL, UNIQUE, PRIMARY_KEY.
string
Column description.
array
Semantics rules defining business expectations.
Show properties
string
required
Rule name (e.g., hasOwner, hasDescription, hasDomain, hasTags).
object
Rule arguments (varies by rule type).
array
References to test cases that must pass.
Show properties
string
required
UUID of the test case.
string
required
Must be testCase.
object
Service level agreement expectations.
Show properties
object
Expected frequency of data updates.
Show properties
integer
required
Number of units between refreshes.
string
required
One of: hour, day, week, month, year.
object
Maximum acceptable latency between data generation and availability.
Show properties
integer
required
Latency value.
string
required
One of: minute, hour, day.
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.
object
How long the data is retained.
Show properties
integer
required
Retention period.
string
required
One of: day, week, month, year.
string
Terms of use in Markdown format. Describes allowed/disallowed use cases and compliance requirements.
import static org.openmetadata.sdk.fluent.DataContracts.*;// client is an initialized OpenMetadataClient.setDefaultClient(client);// Create a data contract with fluent APIDataContract 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();