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

# Multi-Org Setup

Use one folder per organization. Run Deepline from inside that folder.

## Setup

### 1. Create Folders

Create a predictable folder layout with separate input, output, and play files for each org.

<Tabs>
  <Tab title="Prompt" icon="message-square">
    ```text theme={null}
    Organize my workspace into one folder for each organization.
    Put the right data and assets in each folder.
    ```
  </Tab>

  <Tab title="Agent commands" icon="terminal">
    ```bash theme={null}
    mkdir -p ~/deepline/workspaces/acme/{input,output,plays}
    mkdir -p ~/deepline/workspaces/globex/{input,output,plays}
    ```
  </Tab>
</Tabs>

### 2. Set Orgs

Run the folder-scoped org command inside every org folder.

<Tabs>
  <Tab title="Prompt" icon="message-square">
    ```text theme={null}
    Set the Deepline org for each folder using deepline org -h.
    Verify the saved .env.deepline path is inside each folder.
    ```
  </Tab>

  <Tab title="Agent commands" icon="terminal">
    ```bash theme={null}
    cd ~/deepline/workspaces/acme
    deepline org -h
    deepline org list --json
    deepline org set "Acme" --auth-scope folder --json
    test -f .env.deepline
    deepline org status --json
    deepline auth status --json

    cd ~/deepline/workspaces/globex
    deepline org set "Globex" --auth-scope folder --json
    test -f .env.deepline
    deepline org status --json
    ```
  </Tab>
</Tabs>

Final state:

```text theme={null}
~/deepline/
  workspaces/
    acme/
      .env.deepline  # Acme workspace-specific API key
      input/
        leads.csv
      output/
      plays/
    globex/
      .env.deepline  # Globex workspace-specific API key
      input/
        leads.csv
      output/
      plays/
```

The CLI creates `.env.deepline`; you normally should not write it by hand. If `org status` points at a parent folder's `.env.deepline`, remove that parent pin or rerun from the intended org folder after clearing it.

### 3. Run Agents From Folders

Start agents from inside the right org folder for foolproof org usage. You can also start from `~/deepline`, but tell the agent to `cd` into the right workspace folder before it runs `deepline`.

<Tabs>
  <Tab title="Prompt" icon="message-square">
    ```text theme={null}
    Run Deepline from within each folder so the right org API key is used.
    Check the org before running workflows.
    ```
  </Tab>

  <Tab title="Agent commands" icon="terminal">
    ```bash theme={null}
    cd ~/deepline/workspaces/acme
    deepline org status --json
    deepline plays run ./plays/enrich-leads.play.ts --csv input/leads.csv --watch
    deepline runs export <run-id> --out output/leads-enriched.csv
    ```
  </Tab>
</Tabs>

<div className="not-prose my-5 border-t border-gray-200 dark:border-gray-800" />

## Audit folder bindings

Check which org each folder is bound to.

<Tabs>
  <Tab title="Prompt" icon="message-square">
    ```text theme={null}
    Report org status for each folder in my workspace.
    ```
  </Tab>

  <Tab title="Agent commands" icon="terminal">
    ```bash theme={null}
    cd ~/deepline/workspaces/acme && deepline org status --json
    cd ~/deepline/workspaces/globex && deepline org status --json
    ```
  </Tab>
</Tabs>

<div className="not-prose my-5 border-t border-gray-200 dark:border-gray-800" />

## Fix the wrong org

Change only the folder that is wrong, then verify it.

<Tabs>
  <Tab title="Prompt" icon="message-square">
    ```text theme={null}
    This folder should use <ORG_NAME>.
    Check the current org, fix only this folder, then verify it.
    ```
  </Tab>

  <Tab title="Agent commands" icon="terminal">
    ```bash theme={null}
    cd ~/deepline/workspaces/acme
    deepline org status --json
    deepline org set "Acme" --auth-scope folder --json
    deepline org status --json
    ```
  </Tab>
</Tabs>

<div className="not-prose my-5 border-t border-gray-200 dark:border-gray-800" />

## Reference

Run `deepline org -h` for the current org commands and auth-scope behavior.
