{
  "name": "Nodbot - HTTP Request retry and DLQ policy",
  "nodes": [
    {
      "parameters": {
        "path": "retry-dlq-http-request",
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "id": "ff5169fc-76b3-4132-804d-d236645dbad1",
      "name": "Webhook input",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const src = $json.body ?? $json;\nconst status = Number(src.http_status ?? src.statusCode ?? 0);\nconst attempt = Number(src.attempt ?? 1);\nconst maxAttempts = Number(src.max_attempts ?? 5);\nconst idempotencyKey = String(src.idempotency_key ?? src.event_id ?? '').trim();\n\nif (!idempotencyKey) throw new Error('Missing idempotency_key for retry workflow');\n\nconst retryableStatus = [408, 409, 425, 429, 500, 502, 503, 504];\nconst isNetworkError = String(src.error ?? '').toLowerCase().includes('timeout');\nconst retryable = retryableStatus.includes(status) || isNetworkError;\nconst permanentFailure = status >= 400 && status < 500 && !retryable;\nconst delaySeconds = Math.min(900, Math.pow(2, attempt) * 15);\n\nlet route = 'success';\nif (retryable && attempt < maxAttempts) route = 'retry';\nif (retryable && attempt >= maxAttempts) route = 'dlq';\nif (permanentFailure) route = 'dlq';\n\nreturn [{\n  json: {\n    route,\n    idempotency_key: idempotencyKey,\n    attempt,\n    max_attempts: maxAttempts,\n    next_attempt: attempt + 1,\n    retry_after_seconds: delaySeconds,\n    status,\n    reason: src.error ?? src.response?.message ?? 'classified_by_retry_policy',\n    original_payload: src.original_payload ?? src\n  }\n}];"
      },
      "id": "61db4330-34c2-498f-8948-2305f666e606",
      "name": "Prepare HTTP request",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        260
      ]
    },
    {
      "parameters": {},
      "id": "55e30074-3754-43d0-b729-6e12e87f6ac6",
      "name": "Send HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        560,
        260
      ]
    },
    {
      "parameters": {},
      "id": "dba9f6bd-bfbf-4d47-84ed-9e52eb9157e5",
      "name": "Classify API response",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        840,
        260
      ]
    },
    {
      "parameters": {},
      "id": "0cdee2cc-f381-4955-bd49-c8b0716fad9c",
      "name": "Retry gate",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1120,
        260
      ]
    },
    {
      "parameters": {},
      "id": "f26acae9-7927-4e17-83f0-b19ba55e9013",
      "name": "Write DLQ record",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1400,
        260
      ]
    },
    {
      "parameters": {},
      "id": "7ec5770e-fad3-45d7-b250-2a76b1cc62d5",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 2,
      "position": [
        1680,
        260
      ]
    }
  ],
  "connections": {
    "Webhook input": {
      "main": [
        [
          {
            "node": "Prepare HTTP request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare HTTP request": {
      "main": [
        [
          {
            "node": "Send HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send HTTP Request": {
      "main": [
        [
          {
            "node": "Classify API response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify API response": {
      "main": [
        [
          {
            "node": "Retry gate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retry gate": {
      "main": [
        [
          {
            "node": "Write DLQ record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write DLQ record": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "nodbot",
    "production",
    "template"
  ],
  "triggerCount": 1,
  "updatedAt": "2026-05-30T00:00:00.000Z",
  "versionId": "1a4eb254-1799-4af8-b17b-065281dc6faf",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}