> For the complete documentation index, see [llms.txt](https://docs.soda.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.soda.io/soda-documentation/data-testing/git-managed-data-contracts/install-and-configure.md).

# Configure your environment

Before you can define, test, or verify Git-managed data contracts, you need to install the Soda CLI and configure your environment.

This setup gives you full control over your contracts, letting you version them in Git, execute them locally or remotely, and integrate them into your CI/CD pipelines.

## 1. Install the Soda Core Python Package

> If you haven't already, follow the [Soda Core installation flow](/soda-documentation/deployment-options/soda-python-libraries.md) to set up your environment, set your credentials, and install the necessary Soda extensions.

## 2. \[Optional] Connect to Soda Cloud

If you want to interact with Soda Cloud to **publish contracts** and **view verification results**, or to **use Soda Runner**, you’ll need to connect the CLI to your Soda Cloud account.

> Don’t have an account? [Book a demo](https://soda.io/demo?utm_source=documentation\&utm_medium=cloud_docs\&utm_campaign=demo_request\&utm_content=connect_soda_cloud) to get started.

### Create the config file

Run the following command:

```shellscript
soda cloud create -f sc_config.yml
```

This generates a basic Soda Cloud configuration file:

{% code title="sc\_config.yml" %}

```yaml
soda_cloud:
  host: cloud.soda.io        ##change to cloud.us.soda.io, depending on your Soda region
  api_key_id: ${SODA_CLOUD_API_KEY_ID}
  api_key_secret: ${SODA_CLOUD_API_KEY_SECRET}
```

{% endcode %}

#### Add your API keys

To add your API keys, you can do **one** of the following:

* Set environment credentials, as directed in the [Private PyPi installation flow](/soda-documentation/deployment-options/soda-python-libraries.md#private-pypi-installation-flow), or
* Open `sc_config.yml` and fill in your API key and organization details.

> Learn more about how to [generate API keys](broken://pages/H6Piqnv5lUFCAv1Cvm75).

### Test the connection

Run the following command:

```shellscript
soda cloud test -sc sc_config.yml
```

<i class="fa-octagon-check">:octagon-check:</i> This ensures the CLI can authenticate and communicate with Soda Cloud. A successful connection will return:

```
  __|  _ \|  \   \\
\__ \ (   |   | _ \\
____/\___/___/_/  _\\ CLI v4.0.4b24
Testing soda cloud file sc_config.yml
✅ Success! Tested Soda Cloud credentials in 'sc_config.yml'
```

## 3. Configure your data source

To verify a contract, Soda needs to know how to connect to your data source. You have **two options**:

### Connect with Soda Core

If you prefer to define your own connection locally (or aren’t using a Soda Runner), you can create a data source config file for **Soda Core**.

Install the required package for your data source.\
For example, for PostgreSQL:

```shellscript
pip install -i https://pypi.cloud.soda.io/simple --pre -U "soda-postgres>4"
```

> See the [Data source reference for Soda Core](/soda-documentation/reference/data-source-reference-for-soda-core.md) for supported packages and configurations.

#### Create the config file

```shellscript
soda data-source create -f ds_config.yml
```

Open `ds_config.yml` and provide the necessary credentials.

For example, with PostgreSQL:

{% code title="ds\_config.yml" %}

```yaml
type: postgres
name: postgres
connection:
  host: host_name
  port: 5432
  user: user_name
  password: ${env.SODA_DEMO_POSTGRES_PW}
  database: db_name
```

{% endcode %}

> Refer to the [Data source reference for Soda Core](/soda-documentation/reference/data-source-reference-for-soda-core.md) for the configurations of each data source type.

{% hint style="info" %}
**Avoid hardcoding secrets**. Use environment variables or a secrets manager where possible.
{% endhint %}

#### Test the connection:

```shellscript
soda data-source test -ds ds_config.yml
```

### Use an existing Data Source via Soda Runner

If your data source is already connected to Soda Cloud using a **Soda Runner** (hosted or self-hosted), you can reuse that connection without managing credentials or configs locally.

You just need to ensure you have [set up the connection with Soda Cloud](#id-2.-optional-connect-to-soda-cloud).

***

Choose the method that best fits your setup:

* **Soda Runner** for a centralized, cloud-managed connection.
* **Local configuration** if you want full control within your environment.

<br>

***

{% hint style="info" %}
You are **not logged in to Soda** and are viewing the default public documentation. Learn more about [Licensing & documentation access](/soda-documentation/reference/documentation-access-and-licensing.md).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.soda.io/soda-documentation/data-testing/git-managed-data-contracts/install-and-configure.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
