> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcollate.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

# Create a Data Contract

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

**name** `string` *required*

Name of the data contract. Must be unique.

**entity** `object` *required*

Reference to the data asset this contract applies to.

**properties**

**id** `string` *required*

UUID of the entity.

**type** `string` *required*

Entity type: `table`, `topic`, `apiEndpoint`, `dashboardDataModel`, `storedProcedure`, `database`, `databaseSchema`, `dashboard`, `chart`, `pipeline`, `searchIndex`, `apiCollection`, `mlmodel`, `container`, `dataProduct`.

**displayName** `string`

Human-readable display name.

**description** `string`

Description in Markdown format.

**entityStatus** `string` (default: Draft)

Contract status: `Draft`, `In Review`, `Approved`, `Rejected`, `Deprecated`, or `Archived`.

**schema** `array`

Expected column definitions. Each item follows the Column schema.

**properties**

**name** `string` *required*

Column name.

**dataType** `string` *required*

Data type (e.g., `INT`, `VARCHAR`, `TIMESTAMP`).

**constraint** `string`

Constraint: `NULL`, `NOT_NULL`, `UNIQUE`, `PRIMARY_KEY`.

**description** `string`

Column description.

**semantics** `array`

Semantics rules defining business expectations.

**properties**

**name** `string` *required*

Rule name (e.g., `hasOwner`, `hasDescription`, `hasDomain`, `hasTags`).

**args** `object`

Rule arguments (varies by rule type).

**qualityExpectations** `array`

References to test cases that must pass.

**properties**

**id** `string` *required*

UUID of the test case.

**type** `string` *required*

Must be `testCase`.

**sla** `object`

Service level agreement expectations.

**properties**

**refreshFrequency** `object`

Expected frequency of data updates.

**properties**

**interval** `integer` *required*

Number of units between refreshes.

**unit** `string` *required*

One of: `hour`, `day`, `week`, `month`, `year`.

**maxLatency** `object`

Maximum acceptable latency between data generation and availability.

**properties**

**value** `integer` *required*

Latency value.

**unit** `string` *required*

One of: `minute`, `hour`, `day`.

**availabilityTime** `string`

Time of day by which data is expected to be available (for example, `09:00 UTC`).

**timezone** `string`

Time zone for the availability time. Defaults to UTC.

**retention** `object`

How long the data is retained.

**properties**

**period** `integer` *required*

Retention period.

**unit** `string` *required*

One of: `day`, `week`, `month`, `year`.

**termsOfUse** `string`

Terms of use in Markdown format. Describes allowed/disallowed use cases and compliance requirements.

**security** `object`

Security and access policy expectations.

**properties**

**accessPolicy** `string`

Access policy description.

**requiredClassifications** `array`

Required classification tags (e.g., `PII.Sensitive`).

**owners** `array`

Owner references (users or teams).

**reviewers** `array`

Reviewer user references.

**effectiveFrom** `string`

ISO 8601 date from which this contract is effective.

**effectiveUntil** `string`

ISO 8601 date until which this contract is effective.

```python POST /v1/dataContracts theme={null}
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}")
```

```java POST /v1/dataContracts theme={null}
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();
```

```bash POST /v1/dataContracts theme={null}
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"
    }
  }'
```

```json Response theme={null}
{
  "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)

Use `PUT /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 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.