{
  "name": "FormRail - fill an existing PDF",
  "nodes": [
    {
      "parameters": {},
      "id": "trigger",
      "name": "Run example",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://formrail.voltenworks.com/examples/template.pdf",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "template",
      "name": "Download template",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const bytes = await this.helpers.getBinaryDataBuffer(0, 'data');\nreturn [{json:{pdf:bytes.toString('base64'),data:{ProjectName:'September installation',Reference:'JOB-1042',Service:'Installation',Ready:true},flatten:true}}];"
      },
      "id": "encode",
      "name": "Build request",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://formrail.voltenworks.com/v1/fill",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "=formrail-{{$execution.id}}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $json }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "fill",
      "name": "Fill PDF (set Header Auth credential)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        0
      ]
    }
  ],
  "connections": {
    "Run example": {
      "main": [
        [
          {
            "node": "Download template",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download template": {
      "main": [
        [
          {
            "node": "Build request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build request": {
      "main": [
        [
          {
            "node": "Fill PDF (set Header Auth credential)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "pinData": {},
  "tags": []
}
