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

# Set up the Darpan CLI

> Turn on the CLI for your tenant, install it, sign in, and use it from your terminal or Claude Code.

The Darpan CLI puts your tenant's runs, results, and audit findings one command away, so you or an AI assistant such as Claude Code can read them without clicking through the app. Setup takes about five minutes. The only step you cannot do alone is the first one: a Darpan admin has to turn the CLI on for you.

The CLI acts as you. It reaches only the tenants you belong to and only what your role there allows.

## Before you start

* A Darpan account you can sign in to at [app.drpn.ai](https://app.drpn.ai).
* The CLI turned on for you in each tenant you want to use it in. See [Turn on the CLI](#turn-on-the-cli).
* A Mac with [Homebrew](https://brew.sh) and Node 22.18 or newer. Check with `node --version`; if it shows none or an older version, install Node from [nodejs.org](https://nodejs.org).

## Turn on the CLI

CLI access is off by default and set per tenant. A Darpan admin turns it on for you in a tenant, with an end date. Darpan admins need no access of their own.

To ask for it:

**1. Open User settings**

Open **Ask Darpan** with `Cmd/Ctrl+K` and search for **Open User Settings**, or go to `/settings/user`. Check that the active tenant is the one you want the CLI in.

**2. Request access**

In **CLI sessions**, the **CLI in \<tenant>** card says whether the CLI is on for you. If it is not, add what you need it for in **What it is for (optional)** and choose **Request access in \<tenant>**.

**3. Wait for a Darpan admin**

The card shows **Requested \<date>. A Darpan admin will turn it on.** When the request is approved, the card shows the CLI as on and when it ends. If it is declined, the card shows the date and the admin's note, and you can ask again.

## Install

```bash theme={null}
brew tap drpn-ai/tap
brew trust --formula drpn-ai/tap/darpan
brew install darpan
```

Homebrew 7 and later refuse formulas from a tap you have not trusted, so `brew install` alone stops with **Refusing to load formula drpn-ai/tap/darpan from untrusted tap**. The `brew trust` line trusts only the darpan formula. Check the install with `darpan version`.

## Sign in

Signing in links the CLI on this machine to your Darpan user. You approve it in the browser, so your password never goes through the terminal.

**1. Start the sign-in**

```bash theme={null}
darpan login
```

The terminal prints **Enter this code in your browser:** followed by a code like `BCDF-GHJK`, and opens the **Approve CLI** page at `app.drpn.ai/cli-login`. Sign in to the app if it asks.

**2. Enter the code**

Type the code into **Code from your terminal?** and choose **Continue**. The code works for 10 minutes.

**3. Check and approve**

The page asks **Approve Darpan CLI on** *computer name*?, with **Started** and **Expires** below. The computer name is the one the CLI sent. Approve only a code you just started in your own terminal, then choose **Approve**. **Deny** turns the request down.

With [two-factor](https://docs.drpn.ai/guides/two-factor.md) on, **Approve** opens your passkey prompt when you have a passkey. **Use the app code** asks for **Current code from your app** instead.

The page shows **Approved.** and **Return to your terminal.** The terminal prints your username and when the sign-in ends.

If the page says **The Darpan CLI is not turned on for you in \<tenant>**, the request card appears on the same page. Ask for access there, then run `darpan login` again once it is approved.

## Choose a tenant

Every command runs in one tenant. List yours and pick one:

```bash theme={null}
darpan tenants
darpan tenant use <tenant-id>
```

The choice is saved on this machine. To use a different tenant for one command, add `--tenant <tenant-id>`. Check who and where you are with `darpan whoami`.

## First commands

| Command | What it does |
| - | - |
| `darpan runs` | The saved runs you can start. |
| `darpan run start <id>` then `darpan run wait <id>` | Start a saved run and wait for it to finish. |
| `darpan result <id>` | A run's result, or only its differences. |
| `darpan audits` and `darpan report` | Your tenant's audits, and one morning's audit report as the audit page shows it. |
| `darpan findings list` and `darpan findings show <id>` | Audit findings, filtered and paged; one finding in full. |
| `darpan findings by-order` | Every open finding, past the report's 50: one row per order, with its lines folded in, and one per return or credit memo. From `darpan` 0.7.3, add `--state acknowledged` or `--state all` for the others. |
| `darpan guide` | The usual path, limits, and what each role can do. |
| `darpan help` | Every command. From `darpan` 0.7.3, `darpan <command> --help` or `darpan help <command>` shows that command's flags. |

Commands print JSON. The CLI can do anything your role lets you do in the app, and the server checks your role on every call. It reads data, starts and cancels runs, plays audits and re-checks findings, and asks a connected system a fresh read-only question. With `darpan` 0.3.0 or later, it also makes the changes your role allows. Connection passwords, tokens and keys, sign-in, two-factor, passkeys, CLI access, and Shopify or Slack installs stay in the app. A secret given to an AI assistant is kept in its transcript.

### Change a run's conclusions and sync an automation

A Tenant admin or Company editor can also change a run's conclusions and keep an automation in step with its run. These need `darpan` 0.2.4 or later.

| Command | What it does |
| - | - |
| `darpan conclusions show <savedRunId>` | The run's conclusions, in the shape `conclusions save` takes. |
| `darpan conclusions save <savedRunId> --file <json>` | Replaces the run's whole conclusion list. It shows what each conclusion gains, loses or changes, and saves only with `--yes`. |
| `darpan conclusions code --label <text>` | Makes a conclusion name of the tenant's own. |
| `darpan automation sync <automationId>` | Copies the run's source setup and filters onto its automation. It shows whether the automation is in sync, which parts would change, and both sides' filters, and writes only with `--yes`. |

Start a save from `conclusions show`, edit the file, then save it: a save replaces every conclusion, so a partial list would drop the rest. `conclusions save` refuses an empty or malformed list. Each change is credited to you in **Config history**, as an edit in the app would be.

### Look up any order

With `darpan` 0.6.0 or later and Darpan 3.5.0 or later, `darpan lookup <id>` finds an id in what Darpan already holds: a Shopify order id or name, a refund or return id, a HotWax order or return id (with or without `#`), or a NetSuite number, in any spelling. It answers from Darpan's ID index, built from every run and kept copy Darpan reads, and calls none of your connected systems. It shows:

* The records that carry the id in each system, and the records they connect to, such as a HotWax order's Shopify order or a NetSuite sales order's fulfillments.
* The open findings on any of them, including findings on an order's lines.

An id no Darpan run has read yet comes back as not seen: **No Darpan run has read this id yet.** To read fresh data, re-check the finding or the statement. The index holds identifiers only, never customer details or order contents.

| Command | What it does |
| - | - |
| `darpan lookup <id>` | The records that carry the id, how they connect, and their open findings. |
| `darpan lookup --status` | Whether the ID index is current for each kept copy, and says which ones it is behind. |

A lookup needs view access in the tenant. `darpan lookup --all` is gone in 0.6.0: a lookup never reads your systems, so there is no fuller read to ask for.

### Explain a finding, or mark a cause expected

With `darpan` 0.4.0 or later, a Tenant admin or Company editor can tell Claude why a finding happened ("the order isn't paid yet, the payment preference is missing") and have it filed, together with the findings like it. Claude proposes the change; nothing changes until you say yes.

| Command | What it does |
| - | - |
| `darpan findings lookalikes <id>` | How many of the check's other findings share this one's cause, with a few examples. |
| `darpan cause add --run <savedRunId> --code <code> --when "<field> <OPERATOR> [value]" --words "..."` | Proposes a cause: findings that meet the conditions get it. Make a new code first with `darpan conclusions code --label`. |
| `darpan cause expect --audit <auditId> --check <checkCode> --codes <codes> --words "..."` | Proposes marking causes as expected, so their findings leave the list. |
| `darpan change show <id>` | The proposal: before and after, how many findings it would move, and any values to confirm. |
| `darpan change apply <id> --yes --plan <hash> [--confirm ...]` | Makes the change exactly as shown. It is kept in **Config history**, credited to you. |
| `darpan change revert <id>` | Proposes putting back what an applied change did; show it and apply it the same way. |
| `darpan findings recheck --audit <auditId> --period <period> --statement <code>` | Re-checks every open finding of a statement, so the findings move under the new cause. |

`--words` is what you said, as you said it. Any value in a proposal that is not already in the finding or the audit's setup is listed in `change show`; you see each one, and Claude names it back with `--confirm` before the change is made. If the setup changed since the proposal was planned, run `darpan change plan <id>` and look at it again.

### Make other changes

Any other change goes through `darpan call`. `darpan api` lists every method, and `writes: true` marks the ones that change something. `darpan call` sends those only with `--yes`. Without it, the CLI sends nothing and lists the method's inputs.

| Command | What it does |
| - | - |
| `darpan call <method> --params <json> --yes` | Makes one change: a run, an automation, an audit and its statements, a peak period, a sync pair, a notification route, a query and its schedule, a finding's acknowledgement, or an audit agent proposal. |
| `darpan config restore <versionId>` | Shows what restoring an earlier version from **Config history** would change, and its plan hash. |
| `darpan config restore <versionId> --yes --plan <hash>` | Restores exactly that plan. If the config changed since the preview, nothing is written; preview it again. |

Read the current record first and check what will change before you pass `--yes`. Each change is credited to you in **Config history**, as an edit in the app would be. `darpan` 0.3.0 drops `darpan scripts`, `script` and `deploy`. Use `darpan call` for queries and their schedules.

## Use it from Claude Code

Add the CLI as an MCP server and every command becomes a tool Claude Code can call:

```bash theme={null}
claude mcp add darpan -- darpan mcp
```

Claude Code then works with the same access you have: your tenants, your role, and the same list of allowed methods.

## How long a sign-in lasts

A sign-in lasts 7 days, whatever your role, Darpan admins included. It also stops working when your CLI access for the tenant ends, is paused, or is revoked. When it does, commands say **Your CLI session has expired.** Run `darpan login` again.

## See and end your sign-ins

**User settings** → **CLI sessions** lists each machine signed in to the CLI, with when it signed in and when it expires. Choose **Revoke** to end one, for example on a machine you no longer use.

To sign out on the machine you are on:

```bash theme={null}
darpan logout
```

The CLI keeps its key in `~/.config/darpan`. Signing out removes it.

## If sign-in fails

| The terminal says | What to do |
| - | - |
| **The sign-in was denied in the browser.** | Someone chose **Deny** on the **Approve CLI** page. Run `darpan login` again and approve. |
| **The sign-in code expired before it was approved.** | The 10 minutes ran out, or the CLI is not on for you in that tenant. Check **User settings** → **CLI sessions**, then run `darpan login` again. |
| **You are not signed in.** | Run `darpan login`. |
| **Your CLI session has expired.** | The sign-in reached its 7 days, or your access ended. Run `darpan login`; if it fails, ask for access again. |
| "\<method> changes something; nothing was sent." | That method changes your tenant's data. Check the change, then run the same command with `--yes`. |
| "\<method> is not available to the Darpan CLI." | Connection credentials, sign-in and installs stay in the app. Make that change there. |
| "Two-factor is required for this account. Set it up in the Darpan app, then run darpan login again." | Your role requires two-factor. Set it up in the app (see [Two-factor sign-in](https://docs.drpn.ai/guides/two-factor.md)), then run `darpan login`. |

## Next step

See [Manage users and access](https://docs.drpn.ai/guides/manage-users-and-access.md) for how roles decide what you can see and do in each tenant.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.