Create and edit contracts
With Git-managed contracts, you define your expectations as code using YAML. This gives you full control over how your data is validated, and allows you to manage contracts just like any other code artifact: versioned, tested, and deployed via Git.
To learn all about the structure and supported features, refer to the full specification in the Contract Language reference.
The contract structure includes:
Dataset and column structure
Available check types (
missing,invalid,duplicate,freshness, etc.)Filters (dataset-level and check-level) — Optional
Threshold configuration — Optional
Use of variables — Optional
Scheduling — Optional
...and more
Create a contract
Creating a contract requires having installed the soda package using the Private PyPi installation flow available both for Team and Entreprise license, unless you are using an Agent.
Need access to the private PyPI? Please contact us.
soda contract create bootstraps a contract by introspecting a dataset's schema. It writes a YAML file that lists every column with its data type and adds a single schema: check. You then edit the file to add data-quality checks (missing, invalid, duplicate, freshness, etc.).
Prerequisites
A data source configuration file (for local execution), or a Soda Cloud configuration file (for agent execution).
Access to Soda's private PyPI (see include above) for installing the library.
Local execution
Runs introspection from your machine against the data source.
Agent execution
Delegates introspection to a running Soda Agent. Useful when the data source is only reachable from the agent's network.
Omit -f to send the generated skeleton to Soda Cloud as a draft contract instead of writing a local file.
Parameters
--dataset, -d
Yes
Fully qualified dataset name, slash-separated: <DATA_SOURCE>/<DATABASE>/<SCHEMA>/<TABLE>.
--file, -f
Conditional
Path to the contract YAML file to create. Directories are created if needed. Required unless --soda-cloud is set.
--data-source, -ds
Conditional
Path to a data source YAML config file. Required for local execution; ignored when --use-agent is set.
--soda-cloud, -sc
Conditional
Path to a Soda Cloud YAML config file. Required when --use-agent is set, or when --file is omitted.
--use-agent, -a
No
Run introspection on Soda Agent instead of locally. Default: false.
--no-type-parameters, -ntp
No
Omit data type parameters (precision, scale, length) from generated columns.
--verbose, -v
No
Display detailed logs during execution. Default: false.
What the skeleton contains
A skeleton generated for a retail_orders dataset in PostgreSQL looks like this:
The skeleton contains only a schema: check. No column-level checks (missing, invalid, duplicate, etc.) are generated — add these yourself after reviewing the columns.
Use --no-type-parameters to suppress character_maximum_length, numeric_precision, numeric_scale, and datetime_precision entries if you prefer a shorter contract.
Common errors
Either --file or --soda-cloud must be provided— supply one as an output destination.--use-agent requires --soda-cloud— agent mode needs a Soda Cloud config to reach the agent.
You can now edit the contract and add checks by modifying the file.
Get the most out of your data contracts: head to the Contract Language reference to learn more.
Test your contract
Before publishing or verifying your contract, you can run a test command to ensure the contract is correctly defined and points to a valid dataset.
This will:
Validate the YAML syntax
Confirm that the referenced dataset exists
Check for any issues with variables, filters, or structure
Run this as part of your development workflow or CI to catch errors early.
Verify your contract
Before publishing your contract, you may want to execute it to verify that it runs correctly.
Read more about how to Verify a contract
Publish the Contract
If you have Soda Cloud, once your contract is finalized and tested, you can publish it to Soda Cloud, making it the authoritative version for verification and scheduling.
This action requires the "Manage contract" permission on the dataset; the user is identified based on the API key provided in the Soda Cloud configuration.
Learn more about permissions here: Dataset Attributes & Responsibilities
Learn how to connect the CLI to Soda Cloud: Connect to Soda Cloud
Publishing:
Uploads the contract to Soda Cloud
Makes it available for manual, scheduled, or programmatic verifications
Enables visibility and collaboration through the UI
Once published, the contract becomes the source of truth for the dataset until a new version is published.
You’re now ready to start verifying your contract and monitoring your data.
You are not logged in to Soda and are viewing the default public documentation. Learn more about Documentation access & licensing.
Last updated
Was this helpful?
