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

# Update a Data Contract

> Create or update a data contract with a full request body

# Update a Data Contract

Create a data contract or update it if it already exists, using `PUT /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

**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`, `Archived`, `Deprecated`, `Rejected`, or `Unprocessed`.

**schema** `array`

Expected column definitions. Each item follows the Column schema.

**properties**

**name** `string` *required*

Column name.

**dataType** `string` *required*

Data type (for example, `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*

Name of the rule.

**description** `string` *required*

Description of what the rule checks.

**rule** `string` *required*

Rule definition as a JSON Logic string, for example `{"!!":{"var":"owners"}}`.

**enabled** `boolean` *required*

Whether the rule is enforced.

**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`.

**termsOfUse** `string`

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

**security** `object`

Security and access policy expectations.

**properties**

**dataClassification** `string`

Expected data classification (for example, `Confidential` or `PII`).

**policies** `array`

Intended consumers of the data and the policies that govern their access.

**properties**

**accessPolicy** `string`

Access policy ID or name that governs this data.

**identities** `array`

Groups that are intended consumers of the data.

**rowFilters** `array`

Filters that define which rows each consumer can access. Each filter has a `columnName` and an array of `values`.

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

```bash PUT /v1/dataContracts theme={null}
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": "Has owner",
        "description": "The table must have an owner",
        "rule": "{\"!!\":{\"var\":\"owners\"}}",
        "enabled": true
      },
      {
        "name": "Has description",
        "description": "The table must have a description",
        "rule": "{\"!!\":{\"var\":\"description\"}}",
        "enabled": true
      }
    ],
    "sla": {
      "refreshFrequency": {"interval": 1, "unit": "hour"},
      "maxLatency": {"value": 4, "unit": "hour"}
    }
  }'
```

```python PATCH /v1/dataContracts/{id} 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"
)

# Update contract description and status
contract = DataContracts.update(
    "f7a1b2c3-d4e5-6789-0abc-def123456789",
    description="Updated contract for sales orders table",
    entityStatus="Approved"
)
```

```java PATCH /v1/dataContracts/{id} theme={null}
import static org.openmetadata.sdk.fluent.DataContracts.*;

// client is an initialized OpenMetadataClient.
setDefaultClient(client);

// Update using fluent API
FluentDataContract contract = find(contractId).fetch();
contract.withDescription("Updated contract for sales orders table")
    .withStatus(EntityStatus.APPROVED)
    .save();
```

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

```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",
  "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 (for example, `Draft`, `Approved`, `Deprecated`) |
| `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 patch operations |
| `401` | `UNAUTHORIZED` | Invalid or missing authentication token |
| `403` | `FORBIDDEN` | User lacks permission to update data contracts |


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