{
  "nodes": [
    {
      "id": "f6f6e8fe-0170-4654-84a0-b642ed0e1486",
      "name": "Run Domain Expiry Check",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4378b325-c8e2-45b3-88af-d4f991c39a33",
      "name": "Set Sheet Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        192,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "991ab6f7-c6af-4c72-9750-306a36da2729",
              "name": "Sheet ID",
              "type": "string",
              "value": "1JZVzYT__FJ4XRhberEa0NXQplL1jPavyt4xFV7mOEDo"
            },
            {
              "id": "b1cdcee9-b3dc-43ee-ae9e-8e9fb1c2f465",
              "name": "sites sheet",
              "type": "string",
              "value": " SiteData "
            },
            {
              "id": "0d6c318a-7cf1-4db6-bdf7-95029512ff2b",
              "name": "Email Size",
              "type": "number",
              "value": 30
            },
            {
              "id": "09bf4e99-39ce-4e8d-a865-0be0aae82d5d",
              "name": "",
              "type": "string",
              "value": ""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "baa9ff4b-6a40-4fde-b2b9-7a1f78f35994",
      "name": "Read All Domains from Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        416,
        0
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $json['sites sheet'] }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json['Sheet ID'] }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "9f53094b-671d-4799-a7e0-c36c253d36e0",
      "name": "Loop Through Each Domain",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        688,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "318dfa39-901d-45dc-8aa1-1c116f99e4fe",
      "name": "Fetch DNS Records via WHOIS API",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        976,
        16
      ],
      "parameters": {
        "url": "https://whois-api6.p.rapidapi.com/dns/api/v1/getRecords",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ $json.Websites }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "whois-api6.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "82452f6dc6mshf73d0188debef6dp111399jsn510d2802904b"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3a38d798-4581-43a0-b325-394d39ffc9f0",
      "name": "Convert Expiry Timestamp to Date",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        1200,
        16
      ],
      "parameters": {
        "jsCode": "const expireSeconds = $input.first().json.result.records.SOA[0].expire;\nconst expireDate = new Date(Date.now() + expireSeconds * 1000);\n\nconst day = String(expireDate.getDate()).padStart(2, '0');\nconst month = String(expireDate.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed\nconst year = expireDate.getFullYear();\n\nconst formatted = `${day}-${month}-${year}`;\n\nreturn [{ json: { expireDate: formatted } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "826a501c-74d2-4e64-b878-4debf7ce4fae",
      "name": "Write Expiry Data to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueRegularOutput",
      "position": [
        1424,
        16
      ],
      "parameters": {
        "columns": {
          "value": {
            "Websites": "={{ $('Loop Through Each Domain').item.json.Websites }}",
            "Days Left": "=",
            "Expiry Year": "={{ $json.expireDate.split('-')[2] }}",
            "Expiry Month": "={{ ['January','February','March','April','May','June','July','August','September','October','November','December'][+($json.expireDate.split('-')[1]) - 1] }}",
            "Domain Expiry": "={{ $json.expireDate }}"
          },
          "schema": [
            {
              "id": "Websites",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Websites",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "DA",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "DA",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "PA",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "PA",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "SS",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "SS",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "DR",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "DR",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MSG for Team",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "MSG for Team",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Issue from Team ",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Issue from Team ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Niches",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Niches",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Categories",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Categories",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Backup Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Backup Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Orion Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Orion Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Server",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Server",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Registrar",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Registrar",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Cloudflare",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Cloudflare",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Domain Expiry",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Domain Expiry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Days Left",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Days Left",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Expiry Month",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Expiry Month",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Expiry Year",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Expiry Year",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "GSC AC",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "GSC AC",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Server IP",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Server IP",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Traffic",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Traffic",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Active Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Active Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Renewal",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Renewal",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Google Indexing",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Google Indexing",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Indexing Remark",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Indexing Remark",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": " Pas: Cloudflare",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": " Pas: Cloudflare",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Websites"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Set Sheet Configuration').item.json['sites sheet'] }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set Sheet Configuration').item.json['Sheet ID'] }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "51ffcc2a-5155-4e5e-97c4-dc3b8b0fb229",
      "name": "Pause Before Next Domain",
      "type": "n8n-nodes-base.wait",
      "position": [
        1648,
        16
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "fbc98e3f-e5c1-4712-bf4f-a3a87500cd59",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -240
      ],
      "parameters": {
        "width": 416,
        "height": 688,
        "content": "## Domain Expiry Date Tracker\n\nThis workflow automatically checks domain expiry dates for\nall websites listed in your Google Sheet. It loops through\neach domain one by one, fetches DNS records using the\nWHOIS API, extracts the expiry timestamp, converts it into\na readable date format, and writes the expiry date, month,\nand year directly back into your tracking sheet. Perfect\nfor managing large domain portfolios and staying ahead of\nrenewal deadlines.\n\n## How it works\n1. Reads all website domains from your Google Sheet.\n2. Loops through each domain individually.\n3. Queries the WHOIS API to retrieve DNS SOA records.\n4. Extracts the expiry timestamp and converts it to DD-MM-YYYY.\n5. Writes expiry date, month name, and year to the sheet.\n6. Pauses 30 seconds before processing the next domain.\n\n## Setup steps\n1. Connect your Google Sheets OAuth credentials.\n2. Add your RapidAPI WHOIS API key in the HTTP Request node.\n3. Update Sheet ID and sheet name in \"Set Sheet Configuration\".\n4. List all domains in the \"Websites\" column of your sheet.\n5. Run the workflow manually to update all expiry dates."
      },
      "typeVersion": 1
    },
    {
      "id": "2e4bf207-f971-44ef-b137-5ca2276ecf14",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 208,
        "content": "## Configuration & Data Loading\n\nSets the Google Sheet ID and sheet name,\nthen reads all domain rows from the sheet\nto prepare for expiry checking."
      },
      "typeVersion": 1
    },
    {
      "id": "5168c361-cdff-411e-ac2a-777e32accdcc",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 208,
        "content": "## Expiry Data Fetch & Processing\n\nLoops through each domain, queries WHOIS API\nfor DNS records, then extracts and converts\nthe expiry timestamp into a readable date format."
      },
      "typeVersion": 1
    },
    {
      "id": "31f5faa5-586e-40af-9b99-5715054c3f38",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 224,
        "content": "## Update Sheet & Continue Loop\n\nWrites the expiry date, month, and year\nback to the Google Sheet, pauses briefly,\nthen moves to the next domain in the list."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Run Domain Expiry Check": {
      "main": [
        [
          {
            "node": "Set Sheet Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Sheet Configuration": {
      "main": [
        [
          {
            "node": "Read All Domains from Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Through Each Domain": {
      "main": [
        [],
        [
          {
            "node": "Fetch DNS Records via WHOIS API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pause Before Next Domain": {
      "main": [
        [
          {
            "node": "Loop Through Each Domain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Expiry Data to Sheet": {
      "main": [
        [
          {
            "node": "Pause Before Next Domain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read All Domains from Sheet": {
      "main": [
        [
          {
            "node": "Loop Through Each Domain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch DNS Records via WHOIS API": {
      "main": [
        [
          {
            "node": "Convert Expiry Timestamp to Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Expiry Timestamp to Date": {
      "main": [
        [
          {
            "node": "Write Expiry Data to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}