{
  "name": "API Health Check with Retry and Branch Alert",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [{ "field": "minutes", "minutesInterval": 15 }]
        }
      },
      "id": "ahcr0001-0001-4000-8000-000000000001",
      "name": "Every 15 Minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "url": "={{ $env.API_HEALTH_URL }}",
        "options": {
          "timeout": 8000,
          "response": { "response": { "neverError": true } }
        }
      },
      "id": "ahcr0001-0002-4000-8000-000000000002",
      "name": "Check API Health",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [460, 300]
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 200,
              "operator": { "type": "number", "operation": "equals" }
            }
          ]
        }
      },
      "id": "ahcr0001-0003-4000-8000-000000000003",
      "name": "Healthy Response?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [680, 300]
    },
    {
      "parameters": {},
      "id": "ahcr0001-0004-4000-8000-000000000004",
      "name": "API Healthy (No-op)",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [900, 220]
    },
    {
      "parameters": {
        "url": "={{ $env.API_HEALTH_URL }}",
        "options": {
          "timeout": 8000,
          "response": { "response": { "neverError": true } }
        }
      },
      "id": "ahcr0001-0005-4000-8000-000000000005",
      "name": "Retry Health Check",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [900, 400]
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 200,
              "operator": { "type": "number", "operation": "notEquals" }
            }
          ]
        }
      },
      "id": "ahcr0001-0006-4000-8000-000000000006",
      "name": "Still Unhealthy?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [1120, 400]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": { "__rl": true, "mode": "id", "value": "={{ $env.SLACK_OPS_CHANNEL }}" },
        "text": ":rotating_light: *API Health Check Failed (confirmed)*\n*Endpoint:* {{ $env.API_HEALTH_URL }}\n*Status:* {{ $('Retry Health Check').item.json.statusCode || 'unreachable' }}\n*Time:* {{ $now.toISO() }}\nRetry confirmed failure — manual investigation required.",
        "otherOptions": {}
      },
      "id": "ahcr0001-0007-4000-8000-000000000007",
      "name": "Alert Slack on Failure",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2,
      "position": [1340, 340]
    }
  ],
  "connections": {
    "Every 15 Minutes": {
      "main": [[{ "node": "Check API Health", "type": "main", "index": 0 }]]
    },
    "Check API Health": {
      "main": [[{ "node": "Healthy Response?", "type": "main", "index": 0 }]]
    },
    "Healthy Response?": {
      "main": [
        [{ "node": "API Healthy (No-op)", "type": "main", "index": 0 }],
        [{ "node": "Retry Health Check", "type": "main", "index": 0 }]
      ]
    },
    "Retry Health Check": {
      "main": [[{ "node": "Still Unhealthy?", "type": "main", "index": 0 }]]
    },
    "Still Unhealthy?": {
      "main": [
        [{ "node": "Alert Slack on Failure", "type": "main", "index": 0 }]
      ]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
