{
  "name": "API Health Monitor",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 5
            }
          ]
        }
      },
      "id": "06-schedule-trigger",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -720,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const endpoints = [{ name: 'Orders API', url: 'https://api.example.com/endpoint', expected: [200, 201, 202, 204] }, { name: 'Billing API', url: 'https://api.example.com/endpoint', expected: [200] }];\nreturn endpoints.map((endpoint) => ({ json: { ...endpoint, started_at: Date.now() } }));"
      },
      "id": "06-set-endpoint-list",
      "name": "Set Endpoint List",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -480,
        0
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{$json.url}}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "options": {
          "timeout": 10000,
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "id": "06-http-request",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -240,
        0
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "jsCode": "const endpoint = $('Set Endpoint List').first().json;\nconst statusCode = Number($json.statusCode || $json.status || 0);\nconst healthy = endpoint.expected.includes(statusCode);\nreturn [{ json: { name: endpoint.name, url: endpoint.url, status_code: statusCode, status: healthy ? 'healthy' : 'unhealthy', expected: endpoint.expected, checked_at: new Date().toISOString(), raw: $json } }];"
      },
      "id": "06-status-code-check",
      "name": "Status Code Check",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { ...$json, latency_ms: $json.raw?.headers?.['x-response-time-ms'] || null } }];"
      },
      "id": "06-latency-capture",
      "name": "Latency Capture",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        240,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json.status}}",
              "operation": "equals",
              "value2": "healthy"
            }
          ]
        }
      },
      "id": "06-success-branch",
      "name": "Success Branch",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        480,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { ...$json, log_level: 'info' } }];"
      },
      "id": "06-log-success",
      "name": "Log Success",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        -120
      ]
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { ...$json, log_level: 'warn', alert_candidate: true } }];"
      },
      "id": "06-failure-branch",
      "name": "Failure Branch",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        120
      ]
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { ...$json, logged_at: new Date().toISOString() } }];"
      },
      "id": "06-log-result",
      "name": "Log Result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        960,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { ...$json, notification_note: 'Replace this node with an alert channel for unhealthy endpoints.' } }];"
      },
      "id": "06-optional-notification-placeholder",
      "name": "Optional Notification Placeholder",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1200,
        0
      ]
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Set Endpoint List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Endpoint List": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Status Code Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Status Code Check": {
      "main": [
        [
          {
            "node": "Latency Capture",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Latency Capture": {
      "main": [
        [
          {
            "node": "Success Branch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Success Branch": {
      "main": [
        [
          {
            "node": "Log Success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure Branch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Success": {
      "main": [
        [
          {
            "node": "Log Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Failure Branch": {
      "main": [
        [
          {
            "node": "Log Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Result": {
      "main": [
        [
          {
            "node": "Optional Notification Placeholder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "UTC"
  },
  "versionId": "placeholder-06"
}