CLI

The dcision command line — save an API key, run decisions, list templates, scaffold and validate decision schemas offline — with exit codes for scripts and CI.

@dcision/cli installs the dcision command. Use it to call deployed decisions from a terminal or a script, and to keep decision schemas in version control with offline validation.

Install

Not on npm yet

@dcision/cli isn't published on npm. Build it from a checkout of the Dcision repository; until this page says it is published, a package with this name on npm doesn't come from Dcision — don't install it, in CI least of all.

# In a checkout of the Dcision repository — Node.js 22 and pnpm 10
pnpm install
pnpm --filter "@dcision/cli..." build   # builds @dcision/core, then the CLI

npm install -g ./packages/cli           # puts `dcision` on your PATH, linked to this checkout
dcision --version

The ... after the package name builds the packages the CLI depends on first. Without installing it globally, run node packages/cli/dist/bin.js instead of dcision. It needs Node.js 20 or newer.

Quick start

# Save an API key (prompted, so it stays out of your shell history)
dcision login

# Run a deployed decision
dcision decide lead-qualification \
  --state '{"message":"We need pricing for 500 users and want to start next month.","company_size":500}'

# Print the raw API response, with the full distributions
dcision decide lead-qualification --state-file lead.json --probabilities --json

Commands

CommandDescription
dcision login [--api-key <key>] [--api-url <url>]Save an API key — prompted when omitted, read from stdin when piped.
dcision logoutRemove the stored key.
dcision config listShow the configuration.
dcision config get <key>Print one setting.
dcision config set <key> <value>Change a setting: api-url or output.
dcision decide <slug> [options]Run a deployed decision.
dcision templatesList the built-in templates.
dcision init [file] [--template <id>] [--force]Write a decision schema JSON (default ./decision.json).
dcision validate <file>Validate a decision schema offline.
dcision check-state <schema-file> (--state <json> | --state-file <path>)Validate a state against a schema offline.
dcision --version, dcision --helpVersion and help.

login

dcision login                                  # prompts for the key
dcision login --api-key "$DCISION_API_KEY"     # non-interactive
echo "$DCISION_API_KEY" | dcision login        # reads stdin when piped
dcision login --api-url https://api.dcision.io # also saves the API URL

The key is stored in ~/.config/dcision/config.json with file mode 600 (readable only by you). dcision logout removes it. Prefer --api-key from an environment variable or stdin over typing a key in a command line that ends up in your shell history.

config

KeyValuesDefault
api-urlThe API base URLhttps://api.dcision.io
outputpretty or jsonpretty
dcision config set output json
dcision config get api-url
dcision config list

decide

dcision decide <slug> [--state <json> | --state-file <path> | --stdin] [--probabilities] [--idempotency-key <key>] [--json]
OptionDescription
--state <json>The state as JSON: an object, an array for list decisions, or a quoted string for text decisions — --state '"Hello"'. Plain text is sent as a text state.
--state-file <path>Read the state from a JSON file.
--stdinRead the state from standard input.
--probabilitiesAdd the full distribution of every question (?include=probabilities).
--idempotency-key <key>Use this Idempotency-Key.
--jsonPrint the raw API response instead of the human-readable output — including scores, composites and the token counts in metrics.

Pass the state with one of --state, --state-file or --stdin.

The CLI reads a state as JSON when it is a JSON object, array or string, so it calls and checks decisions with an object, a list or a text state: --state '["Hi!", "Can I get a quote for 50 seats?"]'. Anything else — plain text, a number — is sent as text; a value that starts with { but doesn't parse is sent as text too, with a warning.

decide is safe to retry: it generates an Idempotency-Key when you don't pass one and retries once on network errors with the same key, so a lost response is replayed rather than run — and billed — twice.

The human-readable output shows the decision and version, the action and its reason, one row per question with its result and confidence, the distributions with --probabilities, and the latency, model, estimated cost and execution ID. Use --json for weighted levels, composites and the destinations of the response.

# Pipe states from another tool
jq -c '.lead' event.json | dcision decide lead-qualification --stdin --json

# Text decision
dcision decide spam-detection --state '"Congratulations! You won a gift card, click here."'

# Your own idempotency key, e.g. the record ID
dcision decide support-routing --state-file ticket.json --idempotency-key ticket-55120

templates and init

dcision templates                                       # lists the nine templates: id, name, description
dcision init                                            # writes ./decision.json
dcision init lead.json --template lead-qualification    # starts from a template
dcision init triage.json --template ticket-triage       # a pattern template: speculative fan-out
dcision init lead.json --template lead-qualification --force   # overwrites an existing file

The template ids are lead-qualification, support-routing, spam-detection, agent-routing, rag-relevance, ticket-triage, voice-banking, resume-screening and customer-service-router — see Templates.

init writes a decision schema — the same JSON the app's editor shows under Decision schema. Without --force, it doesn't overwrite an existing file.

validate and check-state

dcision validate decision.json
dcision check-state decision.json --state '{"message":"Hi, can I get a demo?"}'
dcision check-state decision.json --state-file samples/lead-1.json

Both run offline, with the same rules as the app and the API: validate reports every schema issue with its path — questions, structured entries, composites, policies and their and conditions, destinations — and summarizes a valid schema: its state, questions, number of policies and destinations. check-state reports why a state would be rejected with 422 INVALID_STATE — object, text and list states alike. Use them in CI to keep schemas and sample payloads in sync with your code. The engine's token budget, which also counts the questions, is checked by the API when the decision runs.

The CLI doesn't create or deploy decisions. Build and deploy them in the app; use init, validate and check-state to review and test schemas in your repository.

Environment variables

VariableDescription
DCISION_API_KEYAPI key to use — handy in CI, where you don't run login.
DCISION_API_URLAPI base URL. Default https://api.dcision.io.
NO_COLORDisable colored output.

Exit codes

CodeMeaning
0Success.
1Validation failed — an invalid schema or state.
2Usage error — an unknown command, a missing argument or conflicting options.
3API error — the API answered with an error.
4Network error — the API couldn't be reached.
if ! dcision validate decision.json; then
  echo "decision.json is invalid" >&2
  exit 1
fi

On this page