CLI Quickstart
Thedl CLI is the fastest way to drive DraftLift from a terminal, a script, or an AI agent. This page takes you from a fresh install to your first generated draft.
Install
node --version.
1. Log in
dl login opens your browser, authenticates against DraftLift, and writes an API key to ~/.draftlift/credentials.json. If you cannot open a browser (CI, remote shell):
DRAFTLIFT_API_KEY in your environment — the CLI prefers it over the saved credentials file, which makes scripted use trivial:
dl whoami confirms who you are and surfaces the calling key’s metadata:
key object is what we’ll iterate on next.
2. Add a reference material
References give DraftLift source material to draw on. Add one from a URL:--stdin:
3. Generate
content_id, the generated body, token usage, and an estimated cost. Pass --dry-run to see the assembled prompt without spending tokens.
Need to discover what’s available?
--json and --help with concrete examples.
4. Finalize and follow up
After editing in the editor (or from your agent), close the loop:Workspaces
If your account has more than one workspace, every workspace-scoped command accepts a--workspace flag:
--workspace — the server resolves it for you. Passing a different --workspace value against a bound key returns 403 workspace_mismatch. See API Key Scopes & Workspace Binding for the full model.
Scopes in practice
API keys carry one or more scopes. The CLI maps scope errors to a typed exit code (2) with the upgrade URL on its own line:Headless / agent loops
The CLI is designed to be driven by other programs. Every command supports--json, returns a trace_id you can log, and uses non-zero exit codes for typed errors (1=user, 2=auth, 3=server, 4=not found). A minimal agent loop:
Next steps
API Key Scopes
Choose the right scopes and decide when to bind a key to a workspace.
Authentication
Full reference for keys, scopes, workspace binding, and error shapes.
API Overview
Use the same endpoints from any HTTP client.
Templates as Vessels
Understand how templates shape output across platforms.