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

# Create Data Contracts | OpenMetadata Data Contracts

> Create, edit, run, and import data contracts for tables and other data assets in the OpenMetadata UI.

# Create a Data Contract

Data contracts are available for tables, topics, API endpoints, dashboards, pipelines, data products, and most other data assets. For the full list and which sections each asset supports, see [Supported Assets](https://docs.open-metadata.org/v2.1.x-SNAPSHOT/how-to-guides/data-contracts/spec.md#supported-assets).

This guide creates a contract for a table. The form shows only the tabs an asset supports:

| Asset | Form tabs |
| - | - |
| Table | Contract Details, Terms of Service, Schema, Semantics, Security, Quality, SLA |
| Topic, API Endpoint, Dashboard Data Model | Contract Details, Terms of Service, Schema, Semantics, Security, SLA |
| Data Product and other assets | Contract Details, Terms of Service, Semantics, Security, SLA |

Creating a contract requires the **Create** permission on data contracts. Editing or running one requires **Edit All** on the contract.

## Create a Contract in the UI

1. On the asset's table details page, click the **Contract** tab.

   ![Contract Tab](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/contract-tab.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=810dc7e96fbe167b4298ed3c99346b8d)

2. Select **Add Contract** > **Create Contract with UI**.

   ![Create Contract](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/create-contract.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=1f75a36510fc13a60df74744d0a14206)

3. On the **Contract Details** tab, do the following:

   1. Enter a **Contract Title**.
   2. Optional: Add **Owners** and a **Description**, and set the **Status**. New contracts default to **Draft**.

   ![Adding Contract Details](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/contract-details.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=49814afa0c6798ea8fb1fef33ddb4009)

4. Optional: On the **Terms of Service** tab, describe how the data may be used.

5. On the **Schema** tab, select the columns the contract covers, or select all columns with the checkbox in the header. Only top-level columns can be selected.

   ![Schema Tab](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/schema-tab.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=0aa88c4e72687c6a47b4381d1b671231)

6. On the **Semantics** tab, do the following:

   1. Click **Add Semantics**.

      ![Add Semantics](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/add-semantic.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=8adb2bfb74195715bbdc2398a256e547)

   2. Enter a suitable **Name** and **Description**.

   3. Add a **Rule**. The rule builder checks metadata such as owners, description, domain, data product, tags, glossary terms, tier, and status.

      ![Add new rule](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/add-new-rule.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=550d20b7a1975867c0191076f32ef3a1)

   4. Click **Save**.

   Click **Add New Rule** to add more rules to the same semantic, **Add Semantics** to add another semantic, and the toggle switch on each rule to turn it on or off.

   ![Toggle semantics](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/toggle-semantics.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=104492dcf776de98f33f7942896a763f)

7. Optional: On the **Security** tab, do the following:

   1. Enter a **Data Classification**.
   2. Click **Add Policy** and enter the following details:
      * **Access Policy**: Name of the access policy consumers should use.
      * **Identities**: Consumer groups or users, such as Active Directory groups.
      * **Row Filters**: Column-and-value pairs that describe which rows a consumer should see.

   ![Security Tab](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/security-tab.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=147e405545524cb0918fd293e3c6385a)

8. On the **Quality** tab, select the table's existing test cases, or select **Add Test** to create a new [data quality test](https://docs.open-metadata.org/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/create-quality-test-cases.md).

   ![Quality Tab](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/quality-tab.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=def76dcdfae9a7c09bf2024e19283838)

9. Optional: On the **SLA** tab, fill in the following details:

   * **Refresh Frequency**: Expected interval, in hours, days, weeks, months, or years, between data updates.
   * **Max Latency**: Maximum acceptable value, in minutes, hours, or days, between data generation and availability.
   * **Availability Time**: Time of day, such as `09:00`, and timezone by which the data should be available.
   * **Retention**: Period, in days, weeks, months, or years, the data is retained.
   * **Column**: Column that holds the data's refresh time.

   ![SLA Tab](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/sla-tab.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=217f1f8f908ea7f17b926fcdb10ba265)

10. Click **Save**.

For what each section holds and which sections a run checks, see [Contract Sections](https://docs.open-metadata.org/v2.1.x-SNAPSHOT/how-to-guides/data-contracts/spec.md#contract-sections).

## Run a Contract

To check the contract now, open the actions menu on the **Contract** tab and select **Run now**.

![Running an OpenMetadata Data Contract](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/create7.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=9605b16da9ab85e9b89c02f2835d87d1)

A run checks the schema, semantics, quality, and SLA sections. The **Data Contract Validation** application also runs every contract daily at midnight by default. The **Contract** tab shows the result of each section and an **Execution History** chart. For what each result means, see [Running a Contract](https://docs.open-metadata.org/v2.1.x-SNAPSHOT/how-to-guides/data-contracts/spec.md#running-a-contract).

## Manage a Contract

* Click the **Settings** icon and the menu shows the following options:

  | Option | What it does |
  | - | - |
  | **Edit** | Opens the contract form. |
  | **Run now** | Runs the contract. |
  | **Import** | Imports a contract in the OpenMetadata YAML format. |
  | **Import ODCS** | Imports an ODCS contract. See [ODCS Import and Export](https://docs.open-metadata.org/v2.1.x-SNAPSHOT/how-to-guides/data-contracts/odcs.md). |
  | **Export** | Downloads the contract as OpenMetadata YAML. |
  | **Export as ODCS** | Downloads the contract as an ODCS v3.1.0 YAML file. |
  | **Delete** | Permanently deletes the contract and its run history. |

  ![Manage Contracts](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/manage-contracts.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=9041db1107ae0a55b3fb211eb1f639a6)

* Use the view switch next to the **Settings** icon to see the contract as YAML.

  ![YAML view](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/view-toggle.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=5be0dbfef483e9d30fb5a132d353de20)

## Import a Contract

To create a contract from a file instead of the form, select **Add Contract** > **Import OM** for an OpenMetadata YAML file, or **Add Contract** > **Import ODCS** for an ODCS file.

![Import Contracts](https://mintcdn.com/openmetadata/Hp_nRIplt8Cuvzs7/public/images/how-to-guides/contracts/import-contracts.png?fit=max\&auto=format\&n=Hp_nRIplt8Cuvzs7\&q=85\&s=7bc5ac00792c46011365ec60dd8f7f31)

When the asset already has a contract, the import asks how to apply the file:

* **Merge with Existing**: Updates the fields the file sets and keeps the rest.
* **Replace Entire Contract**: Replaces the contract with the file.

> [card] [Data Contract Specification](https://docs.open-metadata.org/v2.1.x-SNAPSHOT/how-to-guides/data-contracts/spec.md)
>
> Every section of a data contract and what OpenMetadata checks.


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