N8N Cheatsheet

๐น ๐๐ง๐ฌ๐ญ๐๐ฅ๐ฅ & ๐๐ญ๐๐ซ๐ญ
โค ๐๐จ๐๐ค๐๐ซ (quick start)
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
โค ๐๐๐๐๐ฎ๐ฅ๐ญ ๐๐: http://localhost:5678
โค ๐๐๐ซ๐ฌ๐ข๐ฌ๐ญ๐๐ง๐ญ ๐๐๐ญ๐: ~/.n8n
(back this up)
๐น ๐๐จ๐ซ๐ ๐๐จ๐ง๐๐๐ฉ๐ญ๐ฌ
โข Nodes = building blocks (APIs, logic, files)
โข Workflows = directed graphs of nodes
โข Items = rows/records flowing through nodes (array of JSONs)
โข Binary Data = files that travel with items
โข Triggers = start workflows (e.g., Webhook, Cron)
โข Executions = individual runs (view logs/data)
โข Credentials = encrypted API keys & logins
โข Error Workflows = catch-all for failures
๐น ๐๐จ๐ฉ๐ฎ๐ฅ๐๐ซ ๐๐ซ๐ข๐ ๐ ๐๐ซ๐ฌ
โค Webhook โ start via HTTP request (great for inbound alerts)
โค Cron / Interval โ scheduled jobs (hourly/daily/weekly)
โค IMAP Email โ react to new emails
โค Polling โ check APIs on a cadence
โค Event/WebSocket โ react to external events (where supported)
๐น ๐๐ฌ๐ฌ๐๐ง๐ญ๐ข๐๐ฅ ๐๐จ๐๐๐ฌ
โข HTTP Request โ call any REST API
โข Set โ add/rename fields; create constants
โข If / Switch โ conditional routing
โข Merge โ combine branches (by index, key, or append)
โข SplitInBatches โ process large lists safely
โข Function / Code โ custom JS transforms
โข Wait โ delays, windows, backoff
โข Spreadsheet File โ CSV/Excel parse/build
โข Database โ Postgres/MySQL/SQLite queries
โข Execute Command โ run CLI (air-gapped or local ops)
๐น ๐๐ฑ๐ฉ๐ซ๐๐ฌ๐ฌ๐ข๐จ๐ง๐ฌ & ๐๐๐ญ๐ ๐๐๐ฉ๐ฉ๐ข๐ง๐
โข Current item field: {{$json.myField}}
โข Other nodeโs output: {{$node["Node Name"].json.other}}
โข Now/time: {{$now}}
, {{$today}}
, {{$fromNow(3600)}}
โข String ops: {{ $json.name.toUpperCase() }}
โข Arrays: {{ $items().map(i => i.json.id) }}
โข Safe pathing: {{ $json["user.profile.email"] }}
โข JMESPath helper (where available): {{ $jmespath($json, 'users[*].email') }}
๐น ๐๐ง๐ฏ ๐๐๐ซ๐ฌ (๐๐๐๐ฎ๐ซ๐ข๐ญ๐ฒ, ๐๐๐ฉ๐ฅ๐จ๐ฒ๐ฆ๐๐ง๐ญ)
Security
N8N_ENCRYPTION_KEY
โ encrypt credentials (must set in prod)N8N_BASIC_AUTH_ACTIVE=true
+N8N_BASIC_AUTH_USER/PASSWORD
(optional)N8N_USER_MANAGEMENT_DISABLED=false
(keep default; use built-in users)
Networking / URLs
N8N_HOST=example.com
N8N_PORT=5678
N8N_PROTOCOL=https
N8N_EDITOR_BASE_URL=https://example.com/
WEBHOOK_URL=https://example.com/
(public URL for webhooks)
Executions / Logs
EXECUTIONS_MODE=regular
(orqueue
)EXECUTIONS_DATA_SAVE_ON_SUCCESS=false
EXECUTIONS_DATA_SAVE_ON_ERROR=true
N8N_LOG_LEVEL=info
(trace|debug|info|warn|error)N8N_METRICS=true
(Prometheus endpoint)
DB & Queue
DB_TYPE=postgresdb
+DB_POSTGRESDB_*
varsQUEUE_BULL_REDIS_HOST=redis
+ port/auth vars (queue mode)
๐น ๐๐๐๐ฅ๐ข๐ง๐ & ๐๐
โข Regular mode: single process handles UI+executions
โข Queue mode:
โ Main (UI/scheduler) + multiple workers (executions)
โ Requires Redis; scale workers horizontally
โข Postgres for production persistence
โข Reverse proxy (Caddy/NGINX) + HTTPS + rate-limit on webhooks
โข Backups: DB, ~/.n8n
, mounted volumes, credentials
๐น ๐๐๐๐ฎ๐ซ๐ข๐ญ๐ฒ ๐๐๐ญ๐ญ๐๐ซ๐ง๐ฌ
โข Store secrets in Credentials, not Function nodes
โข Use Webhook secrets / auth headers; verify signatures
โข Restrict IPs at proxy/WAF; require TLS everywhere
โข Principle of least privilege for API keys
โข Turn on Error Workflow to notify SecOps on failure
โข Prune execution data; log to SIEM (via HTTP/Slack/Syslog node)
๐น ๐๐๐ (๐๐ง๐จ๐ฐ-๐๐ฒ-๐๐๐๐ซ๐ญ)
n8n start
n8n import:workflow --input=myflow.json
n8n export:workflow --id=123 --output=myflow.json
n8n export:credentials --all --output=creds.json
n8n user-management:reset # reset owner/admin
๐น ๐๐๐๐ฎ๐ & ๐๐๐ฌ๐ญ
โข Pin data on nodes to test without re-running upstream
โข Past Executions โ inspect inputs/outputs/errors
โข Add Notes to nodes (gotchas, API quirks)
โข Use Wait for rate-limits / backoff
โข Set Continue On Fail where non-critical
๐น ๐๐จ๐ฆ๐ฆ๐จ๐ง ๐๐จ๐จ๐ฉ๐ฌ & ๐๐๐ ๐ข๐ง๐๐ญ๐ข๐จ๐ง (๐๐๐ญ๐ญ๐๐ซ๐ง)
- HTTP Request (page=1) โ 2) IF (has next?) โ 3) Merge (append)
Use Set/Function to bumppage
param; Wait for backoff.
๐น ๐๐ฌ๐๐๐ฎ๐ฅ ๐๐ ๐๐ง๐ข๐ฉ๐ฉ๐๐ญ๐ฌ (๐ ๐ฎ๐ง๐๐ญ๐ข๐จ๐ง/๐๐จ๐๐)
Map fields
return items.map(i => ({ json: {
id: i.json.id,
email: i.json.user?.email ?? null,
ts: new Date().toISOString()
}}));
Deduplicate by key
const seen = new Set();
return items.filter(i => !seen.has(i.json.id) && seen.add(i.json.id));
Group into batches of N
const N = 100;
const out = [];
for (let i=0;i<items.length;i+=N) out.push({ json: { batch: items.slice(i,i+N).map(x=>x.json) }});
return out;
๐น ๐๐๐๐ฎ๐ซ๐ข๐ญ๐ฒ ๐๐ฎ๐ญ๐จ๐ฆ๐๐ญ๐ข๐จ๐ง ๐๐๐๐ข๐ฉ๐๐ฌ
Real-Time Alert โ Enrich โ Act
- ๐ช๐๐๐ก๐จ๐จ๐ค (from IDS/EDR) โ 2) HTTP Request (VirusTotal/OTX) โ
- IF (malicious) โ 4) Slack/Email + HTTP Request (EDR isolate)
Vuln Scan โ Ticketing
- ๐๐ซ๐จ๐ง โ 2) HTTP Request (scanner API) โ 3) SplitInBatches โ
- If (severity โฅ high) โ 5) HTTP (Jira/GitHub Issues)
Phishing Intake
- ๐๐๐๐ ๐๐ซ๐ข๐ ๐ ๐๐ซ (mailbox) โ 2) Function (extract URLs) โ
- HTTP (threat-intel lookups) โ 4) Google Sheet/DB (log)
๐น ๐๐๐ฌ๐ญ ๐๐ซ๐๐๐ญ๐ข๐๐๐ฌ (๐๐ซ๐จ๐)
โ Set N8N_ENCRYPTION_KEY
before creating credentials
โ Use Postgres + Redis (queue mode) for scale
โ Keep workflows atomic; call Sub-Workflows for reuse
โ Version workflows (export to Git)
โ Establish naming: team-domain:verb-object
(e.g., sec-irt:enrich-indicator
)
โ Monitor with metrics/logs; alert on failures via Error Workflow
โ Back up DB + credentials regularly; test restores
๐น ๐๐๐ฏ๐๐ง๐๐๐
โข Reusable/Sub-Workflows via Execute Workflow node
โข Webhook Auth (HMAC headers / shared secrets)
โข Queues: main + N workers (EXECUTIONS_MODE=queue
)
โข Git Sync (export/import flows in CI)
โข Files/Binary: Move Binary Data โ Spreadsheet File โ S3
โข Data Warehousing: Postgres/MySQL nodes โ ELT into warehouse
โข Prompt/AI: call LLM APIs via HTTP; cache with DB; audit outputs
๐น ๐๐ฎ๐ข๐๐ค ๐๐ก๐๐๐ค๐ฅ๐ข๐ฌ๐ญ (๐๐จ-๐๐ข๐ฏ๐)
โฃ HTTPS via proxy (Caddy/NGINX)
โฃ N8N_ENCRYPTION_KEY
set & stored securely
โฃ Postgres + Redis configured; queue workers sized
โฃ Basic Auth or SSO in front of editor (if needed)
โฃ Error Workflow wired to on-call channel
โฃ Backups scheduled; restore test passed
โฃ Execution data retention tuned (save on error only)
Responses