---
title: Workspace setup
description: Convert a Python project into a dltHub workspace, connect it to the dltHub platform and set up a destination for each profile
keywords: [dlthub platform, workspace, setup, login, connect, environments, profiles, credentials, configuration]
---
# Workspace setup

A workspace ready for the dltHub platform is a regular Python project with a few additions. You can easily convert any existing dlt project into a dltHub workspace. [What is a workspace](what-is-a-workspace.md) explains the local workspace, the remote workspace and its deployments.

Starting from scratch instead? Use `uvx dlthub-start@latest`, which scaffolds a workspace and runs a first pipeline for you — see [Deploy your first pipeline](../getting-started/onboarding.md).

## 1. Enable dltHub platform features

Initialize the workspace:

```cli
uvx dlthub-init@latest
```

`uvx dlthub-init@latest` scaffolds a ready-to-run workspace—the `.dlt/.workspace` marker that turns on workspace mode, local config and secrets, a managed `pyproject.toml`, and the dltHub AI skills your coding agent uses—then installs dependencies with `uv sync`.

The `.dlt/.workspace` marker activates [profile support](./profiles.md) and enables the `dlthub` CLI command (including `dlthub profile` and `dlthub local`). Run `uvx dlthub-init@latest --help` for options like `--no-sync`. If you'd rather flip the toggle by hand, see [Enable workspace mode](../getting-started/installation.md#enable-workspace-mode).

The [AI Harness](../ai-harness/introduction.md) keeps what its toolkits produce in a separate folder, `.dlthub/`. See [Artifact locations](../ai-harness/artifact-locations.md).

## 2. Log in to the dltHub platform

```cli
dlthub login
```

This opens your browser and authenticates the current user. On a remote session, where no browser can reach your machine, use `dlthub login --device` for the device-code flow. The login does not connect the workspace.

## 3. Connect to a remote workspace

You can connect the local workspace to the dltHub platform so that you can deploy it:

```cli
dlthub workspace connect [<workspace>] [--org-id <org_id>]
```

With no argument, an interactive picker is shown, grouped by organization. Here dlt connects the local workspace to a workspace deployment in the default environment, `prod`, and writes the chosen `workspace_id` (and `organization_id`, on the first connect) to `.dlt/config.toml`. To list the workspaces that you have access to, use `dlthub workspace list`.

:::note
The first time you run `dlthub deploy`, `dlthub run`, or `dlthub serve`, the CLI walks you through GitHub OAuth and then prompts you to pick (or create) a workspace — so you can skip steps 2 and 3 entirely.

`organization_id` is write-once. To switch organizations later, remove the line from `.dlt/config.toml` by hand and run `dlthub workspace connect` again.
:::

### One workspace deployment for each environment

In each [environment](profiles.md#how-environments-work), the local workspace is connected to a workspace deployment of its own and deploys there. So `prod` and `staging` never share jobs, job runs or credentials. All workspace deployments of a local workspace belong to one organization.

dlt keeps the connections in the shared `config.toml`, one section for each environment:

```toml
# .dlt/config.toml
[runtime]
organization_id = "..."           # one organization for the whole workspace

[workspace.environment.prod]
workspace_id = "..."              # written by `dlthub workspace connect`

[workspace.environment.staging]
workspace_id = "..."              # written by the first deployment to `staging`
```

dlt writes these sections for you. `dlthub workspace connect` connects the local workspace in the environment of the active profile, else in the default environment. Name another one with `--environment`. The first deployment to another environment connects the local workspace in that environment.

A workspace deployment is named after the local workspace and the environment: the workspace `ingest` deploys to `ingest-staging` in `staging`. The default environment keeps the plain workspace name. To use another name, set `name` in the section of the environment, as `name` under `[workspace.settings]` names the local workspace.

`dlthub profile list` shows the workspace deployment of each environment. `dlthub profile info` shows the one of the active profile.

:::caution
In each environment, a local workspace is connected to only one workspace deployment at a time. If you connect it to a different one, the jobs deployed under the previous connection are deactivated. Their run history stays, but their triggers no longer fire.

Connecting multiple local repositories to the same workspace deployment is not yet supported.
:::

### Connect from CI

CI sets the same values with environment variables, `WORKSPACE__ENVIRONMENT__STAGING__WORKSPACE_ID` for example. For non-interactive auth (CI, scripts), set `api_key` in `secrets.toml` under `[runtime]` instead of relying on the OAuth flow. `api_base_url` defaults to `https://api.dlthub.com` and only needs to be set when targeting a self-hosted control plane.

### Workspaces connected before dlt 1.33.0

A workspace that was connected before dlt 1.33.0 keeps the id of its workspace deployment as `workspace_id` under `[runtime]` in `config.toml`. dlt still reads it as the workspace deployment of the default environment, and nothing needs to change. `dlthub workspace connect` moves it to `[workspace.environment.prod]`, and `dlthub workspace disconnect` removes it. If both are set, even to the same id, dlt stops with an error: remove `workspace_id` under `[runtime]`.

The same key in the settings file of a profile of another environment, `stg.config.toml` for example, connects the local workspace in that environment until its section has a `workspace_id`. In the settings file of a profile of the default environment, it counts as the one in `config.toml`. `RUNTIME__WORKSPACE_ID`, which the platform and CI set, always wins.

## 4. Add pipelines

```cli
dlthub pipeline init <source> <destination>
```

This reuses the same machinery as `dlt init`, so verified sources and templates work as you'd expect. See [Initialize a pipeline](../ingestion/init.md) for templates, verified sources, and the agentic setup.

## 5. Set up destinations for each profile

A [profile](./profiles.md) holds the credentials and settings that the code runs with. A new workspace declares the local profiles `dev` and `tests` and, in the `prod` environment, the remote profiles `prod`, `access` and `no-access`. [How profiles work](./profiles.md#how-profiles-work) says what each one is for.

You can give the destination a name in your pipeline and let each profile say what the name means. First create the settings files of the profiles. A new workspace has only `.workspace`, `config.toml` and `secrets.toml`:

```cli
dlthub profile add dev
dlthub profile add prod
```

**`dev.config.toml`** (local DuckDB):

```toml
[destination.warehouse]
destination_type = "duckdb"
```

**`prod.config.toml`** (production destination):

```toml
[destination.warehouse]
destination_type = "motherduck"
```

**`prod.secrets.toml`** (read/write credentials for batch jobs):

```toml
[destination.warehouse.credentials]
database = "your_database"
password = "your-motherduck-service-token"
```

Here the same `destination="warehouse"` resolves to DuckDB with `dev` and to MotherDuck with `prod`: a setting in the file of a profile overrides the shared `config.toml`. You can swap MotherDuck for any cloud destination, see for example [BigQuery](../../dlt-ecosystem/destinations/bigquery.md), [Snowflake](../../dlt-ecosystem/destinations/snowflake.md), or [filesystem/S3](../../dlt-ecosystem/destinations/filesystem.md).

Interactive jobs such as notebooks read with `access`. Until `access` has settings files, they run with `prod`. To give them read-only credentials, see [Limit the data access of jobs](./profiles.md#limit-the-data-access-of-jobs).

:::warning Security
Files matching `*.secrets.toml` and `secrets.toml` are gitignored by default. Never commit secrets to version control. The dltHub platform stores your secrets securely when you sync your configuration.
:::

## Next steps

- [Profiles and environments](profiles.md) — data access, the active profile, and a staging environment
- [Deployments](deployments.md) — quick deploys and the full deployment workflow
- [Triggers and scheduling](triggers.md) — schedule jobs, chain follow-ups, and backfill with intervals
- [Monitoring and debugging](monitoring.md) — watch runs, stream logs, diagnose failures
