| name | n8n-cli |
| description | Use the n8n CLI to manage workflows, credentials, executions, and more on an n8n instance. Use when the user asks to interact with n8n, automate workflows, manage credentials, or operate their instance from the command line. |
| allowed-tools | Bash(n8n-cli:*), Bash(echo:*), Bash(cat:*), Read, Write |
n8n CLI
The n8n-cli command-line tool manages an n8n instance via its REST API.
It auto-detects piped output and switches to JSON, making it composable for scripts and LLM tool use.
Setup
n8n-cli login
n8n-cli config set-url https://my-instance.n8n.cloud
n8n-cli config set-api-key n8n_api_...
export N8N_URL=https://my-instance.n8n.cloud
export N8N_API_KEY=n8n_api_...
Global Flags
Every command supports these flags:
| Flag | Short | Description |
|---|
--url | -u | Instance URL (overrides config/env) |
--apiKey | -k | API key (overrides config/env) |
--format | -f | Output format: table, json, id-only |
--json | | Shorthand for --format=json |
--jq | | jq-style filter (implies --json), e.g. '.[0].id', '.[].name' |
--quiet | -q | Suppress output |
--no-header | | Hide table headers (for awk/cut parsing) |
--debug | | Print HTTP details to stderr |
Auto-JSON: When stdout is piped (not a TTY), output defaults to JSON automatically.
Workflows
n8n-cli workflow list
n8n-cli workflow list --active
n8n-cli workflow list --tag=production
n8n-cli workflow list --name="My Workflow"
n8n-cli workflow list --limit=5
n8n-cli workflow get <id>
n8n-cli workflow get <id> --jq '.nodes[].name'
n8n-cli workflow create --file=workflow.json
cat workflow.json | n8n-cli workflow create --stdin
n8n-cli workflow update <id> --file=updated.json
cat updated.json | n8n-cli workflow update <id> --stdin
n8n-cli workflow activate <id>
n8n-cli workflow deactivate <id>
n8n-cli workflow delete <id>
n8n-cli workflow transfer <id> --project=<projectId>
n8n-cli workflow tags <id>
Executions
n8n-cli execution list
n8n-cli execution list --workflow=<id> --status=error --limit=10
n8n-cli execution get <id>
n8n-cli execution get <id> --include-data
n8n-cli execution retry <id>
n8n-cli execution stop <id>
n8n-cli execution delete <id>
Credentials
n8n-cli credential list
n8n-cli credential get <id>
n8n-cli credential schema notionApi
n8n-cli credential schema slackOAuth2Api
n8n-cli credential create --type=notionApi --name='My Notion' --data='{"apiKey":"..."}'
n8n-cli credential create --type=notionApi --name='My Notion' --file=cred.json
cat cred.json | n8n-cli credential create --type=notionApi --name='My Notion' --stdin
n8n-cli credential delete <id>
n8n-cli credential transfer <id> --project=<projectId>
Tip: Use credential schema <type> to discover required fields before creating.
Projects
n8n-cli project list
n8n-cli project get <id>
n8n-cli project create --name="My Project"
n8n-cli project update <id> --name="New Name"
n8n-cli project delete <id>
n8n-cli project members <id>
n8n-cli project add-member <id> --user=<userId> --role=<role>
n8n-cli project remove-member <id> --user=<userId>
Tags
n8n-cli tag list
n8n-cli tag create --name=production
n8n-cli tag update <id> --name=staging
n8n-cli tag delete <id>
Variables
n8n-cli variable list
n8n-cli variable create --key=API_ENDPOINT --value=https://api.example.com
n8n-cli variable update <id> --key=API_ENDPOINT --value=https://new-api.example.com
n8n-cli variable delete <id>
Data Tables
n8n-cli data-table list
n8n-cli data-table get <id>
n8n-cli data-table create --name=Inventory --columns='[{"name":"item","type":"string"},{"name":"qty","type":"number"}]'
n8n-cli data-table delete <id>
n8n-cli data-table rows <id>
n8n-cli data-table add-rows <id> --file=rows.json
n8n-cli data-table update-rows <id> --file=rows.json
n8n-cli data-table upsert-rows <id> --file=rows.json
n8n-cli data-table delete-rows <id> --ids=row1,row2,row3
cat rows.json | n8n-cli data-table add-rows <id> --stdin
Users
n8n-cli user list
n8n-cli user get <id>
Other
n8n-cli audit
n8n-cli audit --categories=credentials,nodes
n8n-cli source-control pull
n8n-cli config show
Composability Patterns
The CLI is designed to be piped and composed:
n8n-cli workflow list --jq '.[].id'
n8n-cli workflow list --jq '.[0].name'
n8n-cli workflow get 1234 --json > workflow-backup.json
n8n-cli execution list --workflow=1234 --status=error --json
n8n-cli workflow get 1234 --json | jq '.name = "Updated Name"' | n8n-cli workflow update 1234 --stdin
n8n-cli workflow list --no-header | awk '{print $1}'
n8n-cli workflow list --debug 2>debug.log
Workflow JSON Structure
When creating or updating workflows, the JSON follows this structure:
{
"name": "My Workflow",
"nodes": [
{
"name": "Start",
"type": "n8n-nodes-base.manualTrigger",
"position": [250, 300],
"parameters": {}
},
{
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"position": [450, 300],
"parameters": {
"url": "https://api.example.com/data",
"method": "GET"
}
}
],
"connections": {
"Start": {
"main": [[{ "node": "HTTP Request", "type": "main", "index": 0 }]]
}
}
}
Key points:
nodes[].type follows the pattern n8n-nodes-base.<nodeName> for built-in nodes
connections is keyed by source node name, with main output arrays
- Each connection specifies target
node, type (usually main), and output index
- Use
workflow get <id> --json to see real examples from the instance