{
  "name": "HTTP Request Builder",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "http-request",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook Input",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Build HTTP request configuration\nconst input = $input.first().json.body || $input.first().json;\n\n// Default configuration\nconst config = {\n  method: input.method || 'GET',\n  url: input.url,\n  headers: input.headers || {},\n  timeout: input.timeout || 30000,\n  retry: {\n    maxAttempts: input.retry?.maxAttempts || 3,\n    backoffMultiplier: input.retry?.backoffMultiplier || 2,\n    initialDelay: input.retry?.initialDelay || 1000\n  }\n};\n\n// Add body for POST/PUT/PATCH\nif (['POST', 'PUT', 'PATCH'].includes(config.method)) {\n  config.body = input.body || {};\n}\n\n// Validate required fields\nif (!config.url) {\n  throw new Error('URL is required');\n}\n\nreturn {\n  config,\n  attempt: 0,\n  startTime: Date.now()\n};"
      },
      "id": "build-request",
      "name": "Build Request",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "method": "={{ $json.config.method }}",
        "url": "={{ $json.config.url }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": "={{ ['POST', 'PUT', 'PATCH'].includes($json.config.method) }}",
        "bodyParameters": {
          "parameters": [
            {
              "name": "body",
              "value": "={{ JSON.stringify($json.config.body) }}"
            }
          ]
        },
        "options": {
          "timeout": "={{ $json.config.timeout }}"
        }
      },
      "id": "http-request",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Process response\nconst response = $input.first().json;\nconst previous = $('Build Request').first().json;\n\nconst duration = Date.now() - previous.startTime;\n\n// Check for errors\nif (response.statusCode >= 400) {\n  const errorType = \n    response.statusCode === 429 ? 'RATE_LIMIT' :\n    response.statusCode >= 500 ? 'SERVER' :\n    'VALIDATION';\n  \n  return {\n    success: false,\n    error: {\n      type: errorType,\n      message: response.message || 'Request failed',\n      statusCode: response.statusCode,\n      attempt: previous.attempt + 1,\n      maxAttempts: previous.config.retry.maxAttempts,\n      retryable: response.statusCode === 429 || response.statusCode >= 500\n    },\n    duration,\n    config: previous.config\n  };\n}\n\n// Success\nreturn {\n  success: true,\n  data: response,\n  metadata: {\n    statusCode: response.statusCode || 200,\n    duration,\n    attempt: previous.attempt + 1\n  }\n};"
      },
      "id": "parse-response",
      "name": "Parse Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        850,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "retry-condition",
              "leftValue": "={{ $json.success }}",
              "rightValue": false,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            },
            {
              "id": "retryable",
              "leftValue": "={{ $json.error.retryable }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            },
            {
              "id": "attempts-left",
              "leftValue": "={{ $json.error.attempt }}",
              "rightValue": "={{ $json.error.maxAttempts }}",
              "operator": {
                "type": "number",
                "operation": "smaller"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "should-retry",
      "name": "Should Retry?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1050,
        300
      ]
    },
    {
      "parameters": {
        "amount": 5,
        "unit": "seconds"
      },
      "id": "wait-node",
      "name": "Wait (Backoff)",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        1250,
        200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "id": "respond-node",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1250,
        400
      ]
    }
  ],
  "connections": {
    "Webhook Input": {
      "main": [
        [
          {
            "node": "Build Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Request": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Parse Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Response": {
      "main": [
        [
          {
            "node": "Should Retry?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Should Retry?": {
      "main": [
        [
          {
            "node": "Wait (Backoff)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait (Backoff)": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "updatedAt": "2026-03-02T19:00:00.000Z",
  "versionId": "1"
}