5.4 KiB
@n8n/cli
Client CLI for n8n. Manage workflows, executions, credentials, and more from the terminal.
A lightweight, zero-dependency CLI that talks to any n8n instance via its public API. Designed for humans, scripts, and AI coding agents alike.
Installation
# Use directly with npx (zero install)
npx @n8n/cli workflow list
# Or install globally
npm install -g @n8n/cli
Configuration
The CLI needs your n8n instance URL and an API key.
Config file (recommended)
n8n-cli config set-url https://my-n8n.app.n8n.cloud
n8n-cli config set-api-key n8n_api_xxxxx
n8n-cli config show
Configuration is saved to ~/.n8n-cli/config.json with restricted file permissions (0600).
Environment variables
export N8N_URL=https://my-n8n.app.n8n.cloud
export N8N_API_KEY=n8n_api_xxxxx
Inline flags
n8n-cli --url=https://my-n8n.app.n8n.cloud --api-key=n8n_api_xxxxx workflow list
Resolution order
- Command-line flags (
--url,--api-key) - Environment variables (
N8N_URL,N8N_API_KEY) - Config file (
~/.n8n-cli/config.json)
Commands
| Topic | Commands |
|---|---|
workflow |
list, get, create, update, delete, activate, deactivate, tags, transfer |
execution |
list, get, retry, stop, delete |
credential |
list, get, schema, create, delete, transfer |
project |
list, get, create, update, delete, members, add-member, remove-member |
tag |
list, create, update, delete |
variable |
list, create, update, delete |
data-table |
list, get, create, delete, rows, add-rows, update-rows, upsert-rows, delete-rows |
user |
list, get |
config |
set-url, set-api-key, show |
promotion-provider |
list, get, create, update, delete, list-repositories, list-branches |
promotion-environment |
list, get, create, update, delete, connect, disconnect, list-changes, list-apply-changes, promote-check, promote, promote-selection, apply, apply-continue, apply-selection, apply-selection-continue, list-projects, list-missing-projects, create-missing-projects, add-project, remove-project |
promotion-review |
list, get |
source-control |
pull |
package |
export, import (beta), import-selection (beta) |
skill |
install |
audit |
(top-level) |
login / logout |
(top-level) |
Every command supports --help for detailed usage.
Use package export --agent-id=<id> to export Agents. Repeat --agent-id to
select several Agents, or combine it with --workflow-id and --folder-id.
Import the archive with package import --file=<file.n8np>. The shared
--conflict-policy, --id-policy, and --publishing-policy settings apply to
both Agents and workflows. --conflict-policy also applies to the skills of
imported Agents. Only source is supported for --id-policy.
Use package export --skill-id=<id> for selected project or instance Skills.
Use --include-skills with --project-id to include all project Skills.
Import with package import --file=<file.n8np>. Use --skill-id to select Skills
and --delete-skill-id for explicit removals. package import-selection accepts
--selected-skill-ids and --deleted-skill-ids. Skill updates use
--conflict-policy. Published pins remain unchanged.
See package commands
for scopes, defaults, and examples. Agent packages use the ordinary import command.
Output formats
All commands support three output formats via --format:
| Format | Flag | Use case |
|---|---|---|
| Table | --format=table (default) |
Human-readable terminal output |
| JSON | --format=json |
Piping to jq, programmatic use |
| ID-only | --format=id-only |
Piping to xargs, scripting |
# Human-readable table
n8n-cli workflow list
# JSON for scripts
n8n-cli workflow list --format=json | jq '.[] | select(.active) | .id'
# Pipe IDs into another command
n8n-cli workflow list --format=id-only | xargs -I{} n8n-cli workflow deactivate {}
AI agent integration
The CLI ships with a skill file that teaches AI coding agents how to use it.
# Claude Code (project-level)
n8n-cli skill install
# Claude Code (global)
n8n-cli skill install --global
# Cursor
n8n-cli skill install --target=cursor
# Windsurf
n8n-cli skill install --target=windsurf
Development
# Build
pnpm build
# Watch mode
pnpm dev
# Run tests
pnpm test
# Lint & typecheck
pnpm lint
pnpm typecheck
License
See LICENSE.md for details.
Project Preferences, including those in personal projects, instance Preferences, and your own personal Preferences can travel in packages. See Preferences for scope, permission, protection, and format requirements.
| Package flag | Purpose |
|---|---|
export --preference-id=<uuid> |
Export a selected shared or personal Preference. Personal Preferences must belong to you. Repeat for more IDs. |
export --project-id=<id> --include-preferences=true |
Include Preferences from a team or personal project. |
import --preference-conflict-policy=replace |
Explicitly replace changed content for matching IDs. |
import-selection --selected-preference-ids=<uuid> |
Import only selected Preferences. |
import --deleted-preference-ids=<uuid> |
Remove explicit destination rows. Also works with import-selection. |