{
  "name": "Invoice PDF from a webhook (PaperType)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "invoice",
        "responseMode": "responseNode",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://papertype.dev/v1/pdf",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ template: 'invoice', data: $json.body, page_size: 'Letter', filename: $json.body.number + '.pdf' }) }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "data"
            }
          }
        }
      },
      "name": "Render invoice",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [220, 0],
      "credentials": {
        "httpHeaderAuth": {"name": "PaperType API"}
      }
    },
    {
      "parameters": {
        "respondWith": "binary",
        "options": {}
      },
      "name": "Respond with PDF",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [440, 0]
    }
  ],
  "connections": {
    "Webhook": {"main": [[{"node": "Render invoice", "type": "main", "index": 0}]]},
    "Render invoice": {"main": [[{"node": "Respond with PDF", "type": "main", "index": 0}]]}
  }
}
