Expert guidance for n8n workflow automation using REST API and CLI. Use when creating, updating, debugging, or managing n8n workflows...
Comprehensive guidance for efficient n8n workflow automation. This skill provides direct REST API and CLI approaches that are significantly more token-efficient than the MCP server.
Use this skill when:
Choose the right approach based on your task:
| Task | Recommended Approach | Why |
|---|---|---|
| Quick workflow list | scripts/quick-actions.sh |
One command, minimal output |
| Create workflow | REST API + template | Full control, JSON-based |
| Update workflow | REST API | Direct PUT request |
| Debug execution | scripts/execution-manager.py |
Detailed logs and data |
| Bulk operations | Python scripts | Iteration support |
| Complex workflows | Templates + API | Structured starting point |
Ensure these environment variables are set:
export N8N_API_URL="http://localhost:5678" # Your n8n instance
export N8N_API_KEY="your-api-key" # From n8n Settings > API
List all workflows:
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" "$N8N_API_URL/api/v1/workflows" | jq '.data[] | {id, name, active}'
Get specific workflow:
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" "$N8N_API_URL/api/v1/workflows/{id}"
Activate workflow:
curl -s -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" "$N8N_API_URL/api/v1/workflows/{id}/activate"
Trigger webhook workflow:
curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' "$N8N_API_URL/webhook/{path}"
List recent executions:
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" "$N8N_API_URL/api/v1/executions?limit=10" | jq '.data[] | {id, workflowId, status, startedAt}'
Need to work with n8n?
āāā Simple query (list, get, status)?
ā āāā Use: Direct API call or quick-actions.sh
āāā Create/Update workflow?
ā āāā From scratch?
ā ā āāā Use: Template + REST API
ā āāā Modify existing?
ā āāā Use: GET ā modify JSON ā PUT
āāā Debug execution?
ā āāā Use: execution-manager.py
āāā Complex node discovery?
ā āāā Use: MCP search_nodes (only case for MCP)
āāā Bulk operations?
āāā Use: Python scripts
Execute from: ~/.claude/skills/n8n-expert/scripts/
./n8n-api.sh list-workflows # List all workflows
./n8n-api.sh get-workflow <id> # Get workflow JSON
./n8n-api.sh create-workflow <file> # Create from JSON
./n8n-api.sh update-workflow <id> <file>
./n8n-api.sh activate <id>
./n8n-api.sh deactivate <id>
./n8n-api.sh list-executions [workflow-id]
./n8n-api.sh get-execution <id>
./n8n-api.sh trigger <webhook-path> [json-data]
python workflow-crud.py list
python workflow-crud.py get <id>
python workflow-crud.py create <file.json>
python workflow-crud.py update <id> <file.json>
python workflow-crud.py delete <id>
python workflow-crud.py activate <id>
python workflow-crud.py deactivate <id>
python workflow-crud.py export <id> [output.json]
python execution-manager.py list [--status error] [--workflow-id <id>]
python execution-manager.py get <execution-id>
python execution-manager.py debug <execution-id> # Detailed node-by-node output
python execution-manager.py errors [--limit 10] # Recent failed executions
Source this file to get shortcuts:
source ~/.claude/skills/n8n-expert/scripts/quick-actions.sh
n8n-list # List workflows (compact)
n8n-active # List active workflows only
n8n-errors # Recent failed executions
n8n-trigger PATH # Trigger webhook
Located in: ~/.claude/skills/n8n-expert/templates/
workflow-webhook.json - Webhook trigger base templateworkflow-schedule.json - Cron schedule trigger templateworkflow-manual.json - Manual trigger templatenode-configs/http-request.json - HTTP Request node patternsnode-configs/code-node.json - Code node (JS/Python) patternsnode-configs/if-node.json - IF node conditional patternsDetailed documentation in references/:
n8n workflows are JSON objects with this structure:
{
"name": "Workflow Name",
"nodes": [
{
"id": "unique-id",
"name": "Node Name",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [250, 300],
"parameters": { /* node-specific config */ }
}
],
"connections": {
"source-node-id": {
"main": [[{"node": "target-node-id", "type": "main", "index": 0}]]
}
},
"settings": {
"executionOrder": "v1"
}
}
| Node Type | Purpose | Package |
|---|---|---|
webhook |
HTTP trigger | n8n-nodes-base |
scheduleTrigger |
Cron/interval trigger | n8n-nodes-base |
httpRequest |
Make HTTP calls | n8n-nodes-base |
code |
JavaScript/Python code | n8n-nodes-base |
if |
Conditional branching | n8n-nodes-base |
set |
Set/modify data | n8n-nodes-base |
merge |
Merge data streams | n8n-nodes-base |
splitInBatches |
Process items in batches | n8n-nodes-base |
For robust workflows, implement error handling:
{
"nodes": [
{
"name": "Main Node",
"onError": "continueErrorOutput"
},
{
"name": "Error Handler",
"type": "n8n-nodes-base.set"
}
],
"connections": {
"Main Node": {
"main": [[/* success path */]],
"error": [[{"node": "Error Handler", "type": "main", "index": 0}]]
}
}
}
| Operation | MCP Server | Direct API/Script |
|---|---|---|
| List workflows | ~1500 tokens | ~50 tokens |
| Get workflow | ~2000 tokens | ~100 tokens |
| Create workflow | ~3000 tokens | ~200 tokens |
| Debug execution | ~2500 tokens | ~150 tokens |
| Typical savings | - | 90-95% |
Use MCP server only for:
search_nodes for finding unfamiliar nodesget_node for complex node configurationsearch_templates for workflow examplesvalidate_workflow before deploymentFor everything else, direct API/scripts are more efficient.
See references/ for detailed documentation on each topic.