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

# Fetch Use Case

> Download a deployed use case and its metadata documents from the Codika platform, with version selection and list mode

## When to use

* Download a deployed use case from the platform
* Restore a previously deployed use case to local files
* Inspect what documents are stored for a project
* Pull the latest deployed version locally

## Prerequisites

* `codika` CLI installed and authenticated
* Project ID of the deployed use case

## Resolving the project ID

The CLI requires a **project ID**, not a folder path. If the user provides a use case folder path instead, read `project.json` from that folder to get the `projectId`:

```bash theme={null}
cat <use-case-path>/project.json
# Use the "projectId" value in the command below
```

## Command

```bash theme={null}
codika get use-case <projectId> [outputPath] [options]
```

## Arguments

| Argument       | Description                                               |
| -------------- | --------------------------------------------------------- |
| `<projectId>`  | Project ID of the deployed use case (from `project.json`) |
| `[outputPath]` | Output directory (defaults to `./<projectId>`)            |

## Options

| Option                   | Description                                      | Default |
| ------------------------ | ------------------------------------------------ | ------- |
| `--target-version <X.Y>` | Fetch specific version                           | Latest  |
| `--with-data-ingestion`  | Include data ingestion workflow                  | `true`  |
| `--no-data-ingestion`    | Exclude data ingestion workflow                  | —       |
| `--di-version <version>` | Data ingestion version in `X.Y` format           | Latest  |
| `--list`                 | List documents without downloading               | —       |
| `--api-url <url>`        | Override API URL                                 | —       |
| `--api-key <key>`        | Override API key                                 | —       |
| `--profile <name>`       | Use a specific profile instead of the active one | —       |
| `--json`                 | JSON output                                      | —       |

## Behavior

**Download mode** (default):

1. Fetches metadata documents from the API
2. Decodes file content
3. Writes files to the output directory

**List mode** (`--list`):

1. Fetches document listing only
2. Displays file paths, sizes, and content types
3. Does not download any files

## Examples

```bash theme={null}
# Download latest version
codika get use-case abc123

# Download to a specific directory
codika get use-case abc123 ./my-download

# Download a specific version
codika get use-case abc123 --target-version 1.2

# Download without data ingestion
codika get use-case abc123 --no-data-ingestion

# Download with specific data ingestion version
codika get use-case abc123 --di-version 1.0

# List documents without downloading
codika get use-case abc123 --list

# JSON output
codika get use-case abc123 --list --json
```

## Output

### Download mode

```
✓ Downloaded use case
  Project:   abc123
  Version:   1.3
  DI Ver:    1.2
  Files:     8
    config.ts
    version.json
    workflows/main-workflow.json
    workflows/helper.json
    workflows/scheduler.json
    data-ingestion/embedding-ingestion.json
```

### List mode

```
✓ Found 4 document(s)

  Project:      abc123
  Version:      1.0
  DI Version:   1.2
  Organization: org_456

  Documents:
    config.ts  (8.1 KB, text/typescript)
    workflows/main-workflow.json  (5.8 KB, application/json)
    workflows/sub-workflow.json  (2.0 KB, application/json)
    data-ingestion/embedding-ingestion.json  (3.2 KB, application/json)
```

## Exit codes

| Code | Meaning                        |
| ---- | ------------------------------ |
| `0`  | Success                        |
| `1`  | API error or project not found |
