n8n API Skill
Manage n8n automation workflows via the REST API.
Setup
-
Install Bun (if not already installed):
# Linux/macOS curl -fsSL https://bun.sh/install | bash # Windows (PowerShell) powershell -c "irm bun.sh/install.ps1 | iex" -
Get your API key: Settings → API → Create API Key
-
Set environment variables:
export N8N_BASE_URL="https://your-instance.app.n8n.cloud/api/v1" # or http://localhost:5678/api/v1 export N8N_API_KEY="your-api-key"
Quick Reference
Use the TypeScript script with Bun (cross-platform):
| Task | Command |
|---|---|
| List workflows | bun scripts/n8n.ts workflows list |
| Get workflow | bun scripts/n8n.ts workflows get <id> |
| Activate workflow | bun scripts/n8n.ts workflows activate <id> |
| Deactivate workflow | bun scripts/n8n.ts workflows deactivate <id> |
| List executions | bun scripts/n8n.ts executions list [--workflow <id>] [--status <status>] |
| Get execution | bun scripts/n8n.ts executions get <id> |
| Retry execution | bun scripts/n8n.ts executions retry <id> |
| Trigger webhook | bun scripts/n8n.ts webhook <path> '<json-data>' |
| List tags | bun scripts/n8n.ts tags list |
| List variables | bun scripts/n8n.ts variables list |
API Endpoints
Workflows
GET /workflows— List all workflowsPOST /workflows— Create workflowGET /workflows/{id}— Get workflow detailsPUT /workflows/{id}— Update workflowDELETE /workflows/{id}— Delete workflowPOST /workflows/{id}/activate— Activate workflowPOST /workflows/{id}/deactivate— Deactivate workflow
Executions
GET /executions— List executions (supports?workflowId=,?status=)GET /executions/{id}— Get execution detailsDELETE /executions/{id}— Delete executionPOST /executions/{id}/retry— Retry failed execution
Tags
GET /tags— List tagsPOST /tags— Create tagPUT /tags/{id}— Update tagDELETE /tags/{id}— Delete tag
Variables
GET /variables— List variablesPOST /variables— Create variablePUT /variables/{id}— Update variableDELETE /variables/{id}— Delete variable
Credentials
POST /credentials— Create credentialPATCH /credentials/{id}— Update credentialDELETE /credentials/{id}— Delete credentialGET /credentials/schema/{typeName}— Get credential schema
Source Control
POST /source-control/pull— Pull from source control
Webhooks
Webhooks don't use API key auth — they have their own URL path:
curl -X POST "https://your-instance.app.n8n.cloud/webhook/<webhook-path>" \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
Notes
- Pagination: Use
?limit=and?cursor=for large result sets - Rate limits: n8n Cloud has request limits; self-hosted has none by default
- Execution statuses:
success,error,waiting,running - API docs: https://docs.n8n.io/api/api-reference/
Workflow Editing Guidelines
When the user requests modifications to a workflow (not just listing or status changes), you should:
- Fetch the full workflow using
bun scripts/n8n.ts workflows get <id>orGET /workflows/{id} - Parse the JSON structure to understand the nodes, connections, and settings
- Make the requested changes directly to the workflow JSON
- Update the workflow using
PUT /workflows/{id}with the modified JSON
Sticky Notes
When asked to add sticky notes, documentation, or annotations to a workflow:
{
"type": "n8n-nodes-base.stickyNote",
"name": "Sticky Note",
"position": [x, y],
"parameters": {
"content": "Your note content here. Supports **markdown**.",
"height": 200,
"width": 300,
"color": 1
}
}
Sticky note colors: 1 (yellow), 2 (blue), 3 (pink), 4 (green), 5 (purple), 6 (gray), 7 (red)
Position sticky notes near the relevant nodes they describe. Read existing node positions to place notes appropriately.
Common Workflow Modifications
| User Request | Action |
|---|---|
| "Add sticky notes to workflow X" | Fetch workflow, analyze nodes, create stickyNote nodes with descriptions, update workflow |
| "Document workflow X" | Fetch workflow, add sticky notes explaining each section/node group |
| "Rename nodes in workflow X" | Fetch workflow, update node name fields, update workflow |
| "Add error handling to workflow X" | Fetch workflow, add Error Trigger node and notification nodes |
| "Disable node Y in workflow X" | Fetch workflow, set disabled: true on the node, update workflow |
Workflow JSON Structure
{
"id": "123",
"name": "My Workflow",
"active": true,
"nodes": [
{
"id": "uuid",
"name": "Node Name",
"type": "n8n-nodes-base.someNode",
"position": [x, y],
"parameters": { ... },
"disabled": false
}
],
"connections": {
"Node Name": {
"main": [[{ "node": "Next Node", "type": "main", "index": 0 }]]
}
},
"settings": { ... }
}
Part of n8n Skills for Moltbot • Maintained by fazer.ai
