# Contract Autopilot

{% hint style="success" icon="database" %}
Contract Autopilot is currently available as a **preview** for **Snowflake, Postgres, and Databricks** data sources. Contact <support@soda.io> for early access.
{% endhint %}

**Contract Autopilot** automatically generates initial data contracts for datasets with **recommended data quality checks** to accelerate onboarding in Soda Cloud. It is designed to help teams achieve **fast time to value** and iterate later.

#### <i class="fa-camcorder">:camcorder:</i> Watch Contract Autopilot in action

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA2PmHkO5cBgeRPdiPPOG%2Fuploads%2Fi8AsE1XrAzUpzDViJHQA%2Fautopilot%20demo.mp4?alt=media&token=a806f6eb-77e3-484b-ade0-e47c23a5f3bc>" %}

## Generate a contract with Autopilot

{% hint style="warning" %}
This feature requires the **Manage contract** permission on the select datasets. Learn more about permissions here: [dataset-attributes-and-responsibilities](https://docs.soda.io/dataset-attributes-and-responsibilities "mention")
{% endhint %}

{% stepper %}
{% step %}

### Select datasets

On the **Datasets** page, select the datasets for which you want to generate a contract.

Then, click on **Generate Contracts** (top right).

<figure><img src="https://1123167021-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA2PmHkO5cBgeRPdiPPOG%2Fuploads%2FX1smive3w5HMHy3A1LQU%2Fimage.png?alt=media&#x26;token=08dfcc4c-71f7-47af-863f-d4345b9a0f90" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### \[Optional] Set a schedule

You can optionally define a schedule to run contract generation at a time of your choosing.

<figure><img src="https://1123167021-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA2PmHkO5cBgeRPdiPPOG%2Fuploads%2FESDK45yi8aiRugOeKGrS%2Fimage.png?alt=media&#x26;token=ef0df506-c746-4efc-be00-375ee95f963e" alt="" width="340"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Generate

After selecting the datasets, Soda will provide a snapshot of which contracts will be generated, and a time estimate for generation. You can continue using Soda Cloud while contracts are being generated.

After reviewing what will be created, click on **Generate `[num]` Contracts**.

<figure><img src="https://1123167021-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA2PmHkO5cBgeRPdiPPOG%2Fuploads%2F9M0sSaPKo1QUGf1PsEQ7%2Fimage.png?alt=media&#x26;token=487a14ad-0536-4e91-a5fc-f743e2f915b8" alt=""><figcaption></figcaption></figure>

<i class="fa-octagon-check">:octagon-check:</i> You can now **view the generated contracts** to review, edit or suggest changes.
{% endstep %}
{% endstepper %}

This process will create a scan for each selected dataset. You can cancel the scan or review the execution logs in the **Scans** tab on the dataset, as well as on the general **Scans** page.

{% columns %}
{% column width="50%" %}

#### <i class="fa-check">:check:</i> **Successful scan**

* **The generated contract is published.**
  * A **purple checkmark** icon indicates that it is an automatically generated contract.
  * The icon will change to a **blue checkmark** icon after there is a **user edit**, to indicate it is a user-generated contract.
* **A** [**data contract history**](https://docs.soda.io/cloud-managed-data-contracts/author-a-contract-in-soda-cloud#contract-history) **entry is published**, indicating that Autopilot published a first version of the contract.
* \[If configured] A "published contract" Webhook will be published (for example, to allow sync to Git).
  {% endcolumn %}

{% column width="50%" %}

#### <i class="fa-x">:x:</i> **Failed scan**

* The dataset is marked with the message "**Contract generation has failed**".
* **Scan logs** can be reviewed to understand the underlying cause.
* The contract generation can be **re-triggered** after inspecting the root cause.
  {% endcolumn %}
  {% endcolumns %}

***

## Requirements & limitations

{% hint style="info" %}
Autopilot is **only available upon request**. [Contact us](mailto:support@soda.io) to enable it in your organization.
{% endhint %}

Autopilot is currently a Soda Cloud feature:

* A **Soda Agent** is required
* CLI or Python API are not available
* APIs are not available

**Data sources**

* Supported on Snowflake, Databricks, and Postgres connections

**Contract Generation Scope**

Autopilot can only generate data contracts for datasets that do **not** already have an existing data contract. Datasets with an existing contract are not eligible for contract generation via Autopilot.

{% hint style="success" %}
**Contract Autopilot is assistive** and does not autonomously modify data or execute destructive operations. Users can review generated contracts before execution.
{% endhint %}

***

## Privacy & security

Contract Autopilot is designed to minimize data exposure while generating meaningful contract recommendations.

The following data is used locally by Soda:

* A sample of approximately **10,000 rows** to compute profiling metrics

The following data is sent to Soda’s managed OpenAI API:

* A sample of up to 100 rows
* Computed profiling metrics
* Data source type
* Dataset schema

{% hint style="info" %}
Access to Contract Autopilot is **restricted to users with appropriate** dataset **permissions**.
{% endhint %}

> Learn more about [Soda's AI security & privacy measures](https://docs.soda.io/reference/soda-ai#sodas-ai-security-and-privacy-measures).

***

## Next steps

After generation, you can:

* Review generated checks
* Validate assumptions with domain experts
* Adjust schedules and thresholds
* Iterate using [Contract Copilot](https://docs.soda.io/data-testing/broken-reference)

***

#### Contract Autopilot vs. Create Contract

When you click **Create Contract** (or use the CLI `generate` command), Soda creates a **contract skeleton** based on the dataset schema. It includes columns only and **no checks are added**.

**Contract Autopilot**, on the other hand, analyzes sampled data and profiling metadata to automatically generate a **fully populated contract with recommended checks**.

<br>

***

{% if visitor.claims.plan === 'free' %}
{% hint style="success" %}
You are **logged in to Soda** and seeing the **Free license** documentation. Learn more about [documentation-access-and-licensing](https://docs.soda.io/reference/documentation-access-and-licensing "mention").
{% endhint %}
{% endif %}

{% if visitor.claims.plan === 'teams' %}
{% hint style="success" %}
You are **logged in to Soda** and seeing the **Team license** documentation. Learn more about [documentation-access-and-licensing](https://docs.soda.io/reference/documentation-access-and-licensing "mention").
{% endhint %}
{% endif %}

{% if visitor.claims.plan === 'enterprise' || visitor.claims.plan === 'enterpriseUserBased' %}
{% hint style="success" %}
You are **logged in to Soda** and seeing the **Enterprise license** documentation. Learn more about [documentation-access-and-licensing](https://docs.soda.io/reference/documentation-access-and-licensing "mention").
{% endhint %}
{% endif %}

{% if !(visitor.claims.plan === 'free' || visitor.claims.plan === 'teams' || visitor.claims.plan === 'enterprise' || visitor.claims.plan === 'enterpriseUserBased') %}
{% hint style="info" %}
You are **not logged in to Soda** and are viewing the default public documentation. Learn more about [documentation-access-and-licensing](https://docs.soda.io/reference/documentation-access-and-licensing "mention").
{% endhint %}
{% endif %}
