> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Cognite Data Fusion (CDF) is an industrial DataOps platform. Prefer English docs unless the user asks for another locale.
> Follow /_llms/ index links recursively until you reach page URLs ending in .md. Fetch those Markdown twins instead of HTML.
> For REST APIs, default to calendar version 20230101 (stable). Use 20230101-beta or 20230101-alpha only if the user is on a preview API. Cite paths under /api-reference/concepts/<version>/ and the Cdf-Version header. Prefer the Python SDK (cognite-sdk) unless the user is in JavaScript/TypeScript.
> Start here by task: platform overview /cdf/index.md; data modeling /cdf/dm/index.md; data integration /cdf/integration/index.md; access /cdf/access/index.md; CDF Toolkit /cdf/deploy/cdf_toolkit/index.md; REST quickstart /dev/quickstart.md; Python SDK https://cognite-sdk-python.readthedocs-hosted.com/en/stable/; Atlas AI /cdf/atlas_ai/index.md; plan an Atlas AI agent /cdf/atlas_ai/concepts/atlas_ai_agent_planning.md; Flows apps /cdf/flows/index.md; MCP and IDE setup /dev/guides/ide_ai_integration.md.
> For implementation work, also load /skill.md.

# Deploying configurations

> Preview, apply, and delete Cognite Toolkit resources with cdf deploy and cdf clean, using one workflow file as the example.

This article shows how the Cognite Toolkit deploys configurations to a Cognite Data Fusion (CDF) project. Data engineers and Cognite Toolkit administrators use it to preview a change, apply it, and delete the deployed resources.

Before you start, authenticate and keep a `.env` file in the directory where you run the Cognite Toolkit. See [Authenticating with the Cognite Toolkit](https://docs.cognite.com/cdf/deploy/cdf_toolkit/getting_started/auth.md).

**1. Create the workflow configuration**

`cdf deploy` reads the `build/` directory. That path is the default, and `cdf build` normally creates it from your modules. In this example you create it by hand so you can see the files the command sends to CDF.

Create `build/workflows/my.Workflow.yaml`:

```yaml title="my.Workflow.yaml" wrap theme={"languages":{"custom":["/_languages/kuiper.json"]}}
externalId: myWorkflow
description: This workflow performs a specific set of tasks within the module.
```

The directory looks like this:

```shell theme={"languages":{"custom":["/_languages/kuiper.json"]}}
build/
  workflows/
    my.Workflow.yaml
```

The directory name `workflows` and the suffix `.Workflow.yaml` tell the Cognite Toolkit which API to call. This file creates the workflow resource. A workflow that runs tasks also needs a workflow version file. The [resource library](https://docs.cognite.com/cdf/deploy/cdf_toolkit/references/resource_library.md) lists every supported resource.

**2. Preview the deployment**

Run a dry run before you change the CDF project. `--verbose` prints each resource identifier.

```shell theme={"languages":{"custom":["/_languages/kuiper.json"]}}
cdf deploy build/ --dry-run --verbose
```

`build/` is optional because it is the default. The command asks you to type the CDF project name, and that name must match `CDF_PROJECT` in your environment. Cognite Toolkit commands that can change a project use this check. Pass the project on the command line to skip the prompt: `cdf deploy build/ --cdf-project my_demo --dry-run --verbose`.

The output depends on your project and Cognite Toolkit version. This example uses project `my_demo`:

```shell title="Verify project" wrap theme={"languages":{"custom":["/_languages/kuiper.json"]}}
$ cdf deploy build/ --dry-run --verbose
? Enter the name of the CDF project you are deploying. This must match the CDF_PROJECT='my_demo' in your environment variables.
 my_demo
```

The plan lists the target project, the Cognite Toolkit version, and the files in `build/`. One workflow finishes almost immediately.

```shell title="Plan and execution" theme={"languages":{"custom":["/_languages/kuiper.json"]}}
╭─ Setting up deploy operation ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                             │
│  Target project: 'my_demo'                                                                                                                                  │
│  Toolkit version: 0.9.22                                                                                                                                    │
│  Build path: build/                                                                                                                                         │
│                                                                                                                                                             │
│  Processed build directory:                                                                                                                                 │
│    ✓ 1 resource directories                                                                                                                                 │
│    ✓ 1 resource files                                                                                                                                       │
│                                                                                                                                                             │
│  Plan:                                                                                                                                                      │
│  ✓ 1 resource types to deploy                                                                                                                               │
│  ✓ 1 resource files to deploy                                                                                                                               │
│                                                                                                                                                             │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Finished dry-run. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
```

The summary reports what the command would change. Because this is a dry run, the project is still unchanged.

```shell title="Deploy results" theme={"languages":{"custom":["/_languages/kuiper.json"]}}
╭─ Deploy summary (dry run) ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                             │
│                                                                                                                                                             │
│     Resource    Would create   Would update   Would delete   Unchanged   Skipped   Total   Able to deploy                                                   │
│    ───────────────────────────────────────────────────────────────────────────────────────────────────────                                                  │
│     workflows              1              0              0           0         0       1              Yes                                                   │
│                                                                                                                                                             │
│                                                                                                                                                             │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─ Resources (dry run) ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                             │
│  workflows:                                                                                                                                                 │
│  + would create       1 externalId='myWorkflow'                                                                                                             │
│                                                                                                                                                             │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```

The dry run would create one workflow. `--verbose` names that workflow `myWorkflow`. **Able to deploy: Yes** means your credentials can write the workflow to CDF.

**3. Deploy the workflow**

Run the same command without `--dry-run`:

```shell theme={"languages":{"custom":["/_languages/kuiper.json"]}}
cdf deploy build/ --verbose
```

The setup and plan match the dry run. The summary reports one created workflow, `myWorkflow`. The Cognite Toolkit created it with `POST /workflows`. See the [Workflows API](https://docs.cognite.com/api-reference/concepts/20230101/workflows.md).

**4. Deploy the workflow again**

Run the same command a second time. The summary lists `myWorkflow` as unchanged. The Cognite Toolkit reads the workflow from CDF and compares it with `my.Workflow.yaml`. When the file matches the project, it does not send an update.

**5. Update the workflow**

Edit `my.Workflow.yaml`:

```yaml title="my.Workflow.yaml" theme={"languages":{"custom":["/_languages/kuiper.json"]}}
externalId: myWorkflow
description: Updated description
```

Preview the change:

```shell theme={"languages":{"custom":["/_languages/kuiper.json"]}}
cdf deploy build/ --verbose --dry-run
```

`--verbose` prints the description change:

```shell title="Description diff" theme={"languages":{"custom":["/_languages/kuiper.json"]}}
╭─ workflows: externalId='myWorkflow' ──────────────────────────────────────────────╮
│                                                                                   │
│  ---                                                                              │
│                                                                                   │
│  +++                                                                              │
│                                                                                   │
│  @@ -1,2 +1,2 @@                                                                  │
│                                                                                   │
│  -description: This workflow performs a specific set of tasks within the module.  │
│  +description: Updated description                                                │
│   externalId: myWorkflow                                                          │
│                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────╯
Finished dry-run. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
```

The dry run reports one update to `myWorkflow` and **Able to deploy: Yes**. The CDF project is still unchanged. Run the command again without `--dry-run` to apply the new description.

**6. Delete the workflow**

> [!WARNING]
>
> `cdf clean` deletes the resources listed in `build/` from the CDF project. Run the dry run and read the plan before you omit `--dry-run`.

`cdf clean` deletes the resources listed in `build/`. Preview the deletion:

```shell theme={"languages":{"custom":["/_languages/kuiper.json"]}}
cdf clean build/ --verbose --dry-run
```

The dry run lists `myWorkflow` under **Would delete** and **Able to clean: Yes**. Run the command without `--dry-run` to delete it. The summary then reports one deleted workflow.

## Next steps

`cdf build` creates the `build/` directory from modules, including the variable substitution this example skipped. See [Building configurations](https://docs.cognite.com/cdf/deploy/cdf_toolkit/getting_started/build.md).

The [resource library](https://docs.cognite.com/cdf/deploy/cdf_toolkit/references/resource_library.md) lists every file name the Cognite Toolkit can deploy.
