N8N Cheatsheet

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 (or queue)
  • 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_* vars
  • QUEUE_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


๐Ÿ”น ๐‚๐จ๐ฆ๐ฆ๐จ๐ง ๐‹๐จ๐จ๐ฉ๐ฌ & ๐๐š๐ ๐ข๐ง๐š๐ญ๐ข๐จ๐ง (๐๐š๐ญ๐ญ๐ž๐ซ๐ง)

  1. HTTP Request (page=1) โ†’ 2) IF (has next?) โ†’ 3) Merge (append)
    Use Set/Function to bump page 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

  1. ๐—ช๐ž๐›๐ก๐จ๐จ๐ค (from IDS/EDR) โ†’ 2) HTTP Request (VirusTotal/OTX) โ†’
  2. IF (malicious) โ†’ 4) Slack/Email + HTTP Request (EDR isolate)

Vuln Scan โ†’ Ticketing

  1. ๐—–๐ซ๐จ๐ง โ†’ 2) HTTP Request (scanner API) โ†’ 3) SplitInBatches โ†’
  2. If (severity โ‰ฅ high) โ†’ 5) HTTP (Jira/GitHub Issues)

Phishing Intake

  1. ๐—œ๐Œ๐€๐ ๐“๐ซ๐ข๐ ๐ ๐ž๐ซ (mailbox) โ†’ 2) Function (extract URLs) โ†’
  2. 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)

Related Articles

Responses

Your email address will not be published. Required fields are marked *

Click to access the login or register cheese