{
  "id": "zStcO2on6rF2Lbkm",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Get Malaysia Tax ID Number (TIN) for multiple Business Reg Num (SSM) or NRIC",
  "tags": [
    {
      "id": "EjNhH4FcF6aCUyMI",
      "name": "tax",
      "createdAt": "2025-06-08T12:44:04.696Z",
      "updatedAt": "2025-06-08T12:44:04.696Z"
    },
    {
      "id": "hgz17UWMTMTgzdRw",
      "name": "malaysia",
      "createdAt": "2025-06-08T12:43:57.754Z",
      "updatedAt": "2025-06-08T12:43:57.754Z"
    },
    {
      "id": "sN9sWLEjoAmJExut",
      "name": "einvoice",
      "createdAt": "2025-06-08T12:44:02.346Z",
      "updatedAt": "2025-06-08T12:44:02.346Z"
    }
  ],
  "nodes": [
    {
      "id": "bc1c95f4-8e6d-4bb2-89f0-b4bbb355ac34",
      "name": "Search Taxpayer TIN",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        1640,
        500
      ],
      "parameters": {},
      "typeVersion": 4.1
    },
    {
      "id": "07d998a4-54e9-4e21-87e4-5194898e8eac",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        1180,
        360
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a46c6684-f32f-4da5-9531-bc8d627b5350",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1100,
        620
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "f282ad6c-c1ec-4b1b-bc91-150a22f4a4f5",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        -160
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "ffd6cf7d-ca7e-4238-a617-8204d5bef2a7",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2340,
        680
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "463a2904-db33-4aa3-8c5b-fed417dde249",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        1820,
        540
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "718139b2-b844-46a5-8f03-cb15eb6784f8",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "notes": "token still valid?",
      "position": [
        1460,
        580
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 2.2
    },
    {
      "id": "98ebc32e-a15e-4811-bd70-12037f3bc4ab",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        -160
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "22e82f27-98c0-4182-923b-02d79556370d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2020,
        -160
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "169e200f-9700-4150-8b83-c23112e3d312",
      "name": "Setup GSheet Connection",
      "type": "n8n-nodes-base.set",
      "notes": "Setup GSheet connection",
      "position": [
        1640,
        140
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "0e5db648-be9f-4291-b900-32759c774d77",
      "name": "Setup LHDN Connection",
      "type": "n8n-nodes-base.set",
      "notes": "Set lhdn connection credentials",
      "position": [
        1140,
        140
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "8602b739-b553-434c-811d-b241448a3082",
      "name": "Remember token expiry",
      "type": "n8n-nodes-base.set",
      "notes": "track token expiry",
      "position": [
        1800,
        360
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "4d5ba7d4-a5d9-46fb-89dc-2ba4d83a9eb9",
      "name": "Compare token expiry vs now",
      "type": "n8n-nodes-base.code",
      "notes": "check is token still valid",
      "position": [
        1280,
        620
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "6db6c745-6864-43e9-b39d-c8fc59516c70",
      "name": "Wait until token fully expired",
      "type": "n8n-nodes-base.wait",
      "notes": "wait until token fully expired",
      "position": [
        1640,
        660
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 1.1
    },
    {
      "id": "7bd8564e-14fd-408f-9ab2-37fee034e923",
      "name": "Update Google Sheet with TIN not found",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "tin_not_found",
      "position": [
        2080,
        320
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 4.1
    },
    {
      "id": "9bb6a023-e984-4259-abbe-3c0716e00f8a",
      "name": "Update Google Sheet with failure",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "bad_request_or_more_than_1_tin_found",
      "position": [
        2080,
        500
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 4.1
    },
    {
      "id": "efc172ea-b6ac-4890-af3d-ed3ab0090c84",
      "name": "Update Google Sheet with found TIN",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "tin_found and saved",
      "position": [
        2080,
        680
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 4.1
    },
    {
      "id": "8bb6cf93-4885-4618-a1da-150433452016",
      "name": "Get all Google Sheet records to process",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Get rows to process for TIN",
      "position": [
        2080,
        140
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 4.1
    },
    {
      "id": "5b3e185f-cb6e-4b4f-854a-df84d9b85620",
      "name": "Get new LHDN API Token",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "get lhdn api token",
      "position": [
        1480,
        360
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 4.1
    },
    {
      "id": "74fcfc2e-7d86-4d2f-8d66-295d4bed7668",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        -160
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3a19c654-e152-4e20-9cc3-31afb0f7446e",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Search Taxpayer TIN",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait until token fully expired",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Compare token expiry vs now",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Update Google Sheet with TIN not found",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Google Sheet with failure",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Google Sheet with found TIN",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Taxpayer TIN": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remember token expiry": {
      "main": [
        [
          {
            "node": "Get all Google Sheet records to process",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Setup LHDN Connection": {
      "main": [
        [
          {
            "node": "Setup GSheet Connection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get new LHDN API Token": {
      "main": [
        [
          {
            "node": "Remember token expiry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Setup GSheet Connection": {
      "main": [
        [
          {
            "node": "Get new LHDN API Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compare token expiry vs now": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait until token fully expired": {
      "main": [
        [
          {
            "node": "Get new LHDN API Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Google Sheet with failure": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Setup LHDN Connection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Google Sheet with found TIN": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Google Sheet with TIN not found": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all Google Sheet records to process": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}