# Data contract

> A written, checkable promise about the shape and quality of data one team gives another.

- Level: Advanced
- Topics: Data
- URL: https://tidbit.legios.com.ar/data-contract/
- In Spanish: [Contrato de datos](https://tidbit.legios.com.ar/es/data-contract/)

A **data contract** is an agreement between the team that produces some data (say, the engineers of the checkout app) and the teams that consume it (analysts, finance, a machine learning model). It spells out what the data will look like: which fields exist, their types, which ones can be empty, what values are allowed, how fresh the data will be and who to call when something goes wrong. Crucially, it is written as a file in code, usually YAML, so machines can check it.

It exists because of a very common accident. An app developer renames `customer_id` to `client_id` or changes prices from dollars to cents, which is a perfectly reasonable change for the app, and the next morning every revenue dashboard is broken. Nobody did anything wrong; the producer simply did not know who depended on that table. A contract makes the dependency explicit, and an automated check in CI/CD can block the change, or at least warn, before it ships.

Contracts are often versioned like APIs: compatible changes are fine, breaking ones need a new version and a migration period. They are a key idea in data mesh, where each domain team owns and publishes its data as a product. There are open specifications, such as the Open Data Contract Standard, and tools that validate them. The hard part is less the file than the habit: producers have to treat their data as something other people rely on.

## An analogy

A supply agreement between a bakery and the café it delivers to: so many croissants, of this size, by 7 a.m. every day. If the bakery wants to change the recipe, it tells the café first instead of surprising it with baguettes.

## Keep in mind

- Spells out fields, types, allowed values, freshness and owner of a dataset.
- Written as code, so automated checks can catch breaking changes before release.
- Shifts responsibility for data quality toward the team that produces the data.
- Central to data mesh and to treating data as a product.

## Go deeper

- [Data contract on Wikipedia](https://en.wikipedia.org/wiki/Data_contract)
- [Open Data Contract Standard (Bitol)](https://bitol-io.github.io/open-data-contract-standard/)

## Related terms

- [Machine learning](https://tidbit.legios.com.ar/machine-learning/): Teaching computers by showing them examples instead of writing every rule.
- [Dashboard](https://tidbit.legios.com.ar/dashboard/): One screen of charts and numbers that shows how something is doing at a glance.
- [CI/CD](https://tidbit.legios.com.ar/ci-cd/): Automation that builds, tests and ships every code change, so releases become routine.
- [API](https://tidbit.legios.com.ar/api/): The menu of things one program lets another program ask for.
- [Data mesh](https://tidbit.legios.com.ar/data-mesh/): An organizational approach where each business team owns and publishes its own data.
- [Open data](https://tidbit.legios.com.ar/open-data/): Data anyone can freely download, use and share, for any purpose.
- [Semantic versioning](https://tidbit.legios.com.ar/semantic-versioning/): A rule for version numbers like 2.4.1, so each part tells you how risky an update is.
- [Data quality](https://tidbit.legios.com.ar/data-quality/): How far data can be trusted for the job it is used for.
