{
  "name": "API Health Check",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 5
            }
          ]
        }
      },
      "id": "schedule-trigger",
      "name": "Every 5 minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "${API_ENDPOINT}/health",
        "authentication": "none",
        "sendQuery": false,
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "n8n-health-checker/1.0"
            }
          ]
        },
        "options": {
          "timeout": 10000,
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "id": "health-check",
      "name": "Check API Health",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json.statusCode}}",
              "operation": "notEqual",
              "value2": 200
            }
          ]
        }
      },
      "id": "if-unhealthy",
      "name": "Check Status",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "fromEmail": "${ALERT_FROM_EMAIL}",
        "toEmail": "${ALERT_TO_EMAIL}",
        "subject": "API Health Check Failed",
        "text": "=API health check failed at {{$now.toISO()}}\n\nStatus Code: {{$json.statusCode}}\nResponse: {{JSON.stringify($json.body, null, 2)}}\n\nPlease investigate immediately.",
        "options": {}
      },
      "id": "send-alert",
      "name": "Send Alert Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        850,
        200
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "status",
              "value": "healthy"
            },
            {
              "name": "checkedAt",
              "value": "={{$now.toISO()}}"
            }
          ]
        },
        "options": {}
      },
      "id": "log-success",
      "name": "Log Success",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [
        850,
        400
      ]
    }
  ],
  "connections": {
    "Every 5 minutes": {
      "main": [
        [
          {
            "node": "Check API Health",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check API Health": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status": {
      "main": [
        [
          {
            "node": "Send Alert Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": false,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": ""
  },
  "staticData": null,
  "tags": [
    "monitoring",
    "health-check"
  ],
  "triggerCount": 1,
  "updatedAt": "2024-01-01T00:00:00.000Z",
  "versionId": null
}