Bulletproof Workflows
Module 04 · foundations · intermediate
starter.json
In n8n, copy this file and paste it onto the canvas, or use Import from File.
{
"name": "04 - Safe Divide API (starter)",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "divide",
"responseMode": "responseNode",
"options": {}
},
"id": "m04-webhook",
"name": "Divide API",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
0,
100
],
"webhookId": "course-04-divide"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "n1",
"leftValue": "={{ $json.body.a !== '' && $json.body.b !== '' && Number.isFinite(Number($json.body.a)) && Number.isFinite(Number($json.body.b)) }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "m04-valid",
"name": "Numbers?",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
220,
100
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ { error: 'a and b must be numbers' } }}",
"options": {
"responseCode": 400
}
},
"id": "m04-400",
"name": "Respond Bad Input",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
440,
250
]
},
{
"parameters": {
"content": "## Your task\n1. Build a sub-workflow **04 - Divide (sub-workflow)**: inputs `a`, `b` (numbers). If `b == 0` → Stop and Error, else return `result`. **Publish it.**\n2. Here: call it with **Execute Workflow** from the IF's true output.\n3. On that node: Settings → On Error → *Continue (using error output)*. Respond 200 with the result, or 422 with the error.\n4. Build **04 - Error Logger** (Error Trigger → format alert), publish it, and select it in this workflow's Settings → Error Workflow.\n\nTest: `./test/test.sh`",
"height": 260,
"width": 420
},
"id": "starter-task-note",
"name": "Your Task",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
0,
-340
]
}
],
"connections": {
"Divide API": {
"main": [
[
{
"node": "Numbers?",
"type": "main",
"index": 0
}
]
]
},
"Numbers?": {
"main": [
[],
[
{
"node": "Respond Bad Input",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"settings": {
"executionOrder": "v1",
"errorWorkflow": "__WF_ID:learner-error.json__"
}
}