Treat your workflows like code — version control, code review, and automated deployment pipelines ensure quality and traceability.
advanced
Chapter 10: Scaling & Production Best Practices2. Version Control & CI/CD
Export workflows to Git and automate deployments.
15m Lesson 2 of 5
Code Examples
Export Workflows via API
bash
#!/bin/bash
# export-workflows.sh
API_KEY="your-n8n-api-key"
BASE_URL="https://n8n.example.com/api/v1"
# Get all workflows
workflows=$(curl -s -H "X-N8N-API-KEY: $API_KEY" "$BASE_URL/workflows")
# Export each workflow to a JSON file
echo "$workflows" | jq -c '.data[]' | while read workflow; do
wf_id=$(echo "$workflow" | jq -r '.id')
name=$(echo "$workflow" | jq -r '.name' | tr ' ' '_')
echo "$workflow" | jq '.' > "workflows/${name}_${wf_id}.json"
echo "Exported: $name"
donePro Tips
- 💡Use Git branches for workflow changes — develop on feature branches and merge to main for production
Comprehension Quiz
Answer 2 of 2 correctly to unlock lesson completion.
1. How should you treat n8n workflows in a team?
2. What tool exports workflows programmatically?
Pass the quiz above to unlock lesson completion