{
  "name": "Website uptime check to alert",
  "meta": {
    "description": "Every 5 minutes, request a URL. If the first check fails, wait 60 seconds and request it again. Email an alert only if the second check also fails. Placeholder URL and SMTP credentials — attach your own before activating."
  },
  "nodes": [
    {
      "parameters": {
        "content": "## Setup\n1. Replace `https://example.com/` in **Request website**, **Retry request website**, and in the alert email subject and body with the URL you want to check.\n2. Create an SMTP credential in n8n and attach it to **Send down alert** (replace the placeholder).\n3. Set From and To addresses.\n4. After a failed first check the workflow waits **60 seconds**, then requests the URL again. An alert is sent only if the second check also fails. To change the wait, open **Wait 60 seconds** and edit Amount and Unit (currently 60 seconds).\n5. The check treats anything other than HTTP 200, or a missing status (timeout/network error), as down. Adjust the If nodes if you want to accept other 2xx codes.\n6. Test once, then activate. Default interval: every 5 minutes.\n\nNo credentials or secrets are included in this file.",
        "height": 560,
        "width": 380,
        "color": 7
      },
      "id": "c3e3d6f2-8e33-4b9c-9e03-up0000000001",
      "name": "Setup notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -320,
        40
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 5
            }
          ]
        }
      },
      "id": "c3e3d6f2-8e33-4b9c-9e03-up0000000002",
      "name": "Every 5 minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        120,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://example.com/",
        "options": {
          "timeout": 10000,
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true,
              "responseFormat": "text"
            }
          }
        }
      },
      "id": "c3e3d6f2-8e33-4b9c-9e03-up0000000003",
      "name": "Request website",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        360,
        300
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "cond-not-200",
              "leftValue": "={{ $json.statusCode ?? 0 }}",
              "rightValue": 200,
              "operator": {
                "type": "number",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c3e3d6f2-8e33-4b9c-9e03-up0000000004",
      "name": "Status is not 200",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        600,
        300
      ]
    },
    {
      "parameters": {
        "resume": "timeInterval",
        "amount": 60,
        "unit": "seconds"
      },
      "id": "c3e3d6f2-8e33-4b9c-9e03-up0000000006",
      "name": "Wait 60 seconds",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        860,
        180
      ],
      "webhookId": "00000000-0000-4000-a000-000000000060"
    },
    {
      "parameters": {
        "url": "https://example.com/",
        "options": {
          "timeout": 10000,
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true,
              "responseFormat": "text"
            }
          }
        }
      },
      "id": "c3e3d6f2-8e33-4b9c-9e03-up0000000007",
      "name": "Retry request website",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1100,
        180
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "cond-retry-not-200",
              "leftValue": "={{ $json.statusCode ?? 0 }}",
              "rightValue": 200,
              "operator": {
                "type": "number",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c3e3d6f2-8e33-4b9c-9e03-up0000000008",
      "name": "Retry status is not 200",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1340,
        180
      ]
    },
    {
      "parameters": {
        "fromEmail": "monitor@example.com",
        "toEmail": "you@example.com",
        "subject": "=Uptime alert: {{ $json.statusCode ?? 'no status' }} for https://example.com/",
        "html": "=<p>The uptime check failed twice. A retry ran 60 seconds after the first failure, and the second check also did not get HTTP 200.</p><ul><li><strong>URL:</strong> https://example.com/</li><li><strong>First status:</strong> {{ $('Request website').item.json.statusCode ?? 'missing (timeout or network error)' }}</li><li><strong>Second status:</strong> {{ $json.statusCode ?? 'missing (timeout or network error)' }}</li><li><strong>Time:</strong> {{ $now.toISO() }}</li></ul><p>This is an alert from a local n8n workflow template. It is not a hosted monitoring service.</p>",
        "options": {}
      },
      "id": "c3e3d6f2-8e33-4b9c-9e03-up0000000005",
      "name": "Send down alert",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1580,
        60
      ],
      "credentials": {
        "smtp": {
          "id": "PLACEHOLDER_SMTP",
          "name": "SMTP account (placeholder)"
        }
      }
    }
  ],
  "connections": {
    "Every 5 minutes": {
      "main": [
        [
          {
            "node": "Request website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request website": {
      "main": [
        [
          {
            "node": "Status is not 200",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Status is not 200": {
      "main": [
        [
          {
            "node": "Wait 60 seconds",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Wait 60 seconds": {
      "main": [
        [
          {
            "node": "Retry request website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retry request website": {
      "main": [
        [
          {
            "node": "Retry status is not 200",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retry status is not 200": {
      "main": [
        [
          {
            "node": "Send down alert",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/Lisbon"
  },
  "tags": []
}
