{
  "name": "Create a REST API for PDF digital signatures with webhooks",
  "nodes": [
    {
      "id": "a3aa7495-e5a8-4b7f-882a-e642fae414b8",
      "name": "Validate Key Gen Params",
      "type": "n8n-nodes-base.code",
      "position": [
        -220,
        220
      ]
    },
    {
      "id": "6a463b95-04e4-421d-b6e0-46fb98c85e20",
      "name": "Validate PDF Sign Params",
      "type": "n8n-nodes-base.code",
      "position": [
        -220,
        380
      ]
    },
    {
      "id": "cec07784-a42b-4443-ad8e-1bd7686558c3",
      "name": "Validate PDF Upload",
      "type": "n8n-nodes-base.code",
      "position": [
        80,
        -440
      ]
    },
    {
      "id": "1b9304fd-f31d-45c7-8344-01c779e86f0d",
      "name": "Validate Key Upload",
      "type": "n8n-nodes-base.code",
      "position": [
        80,
        -140
      ]
    },
    {
      "id": "efd59edb-6952-4165-ab21-745e03db74eb",
      "name": "Generate Keys",
      "type": "n8n-nodes-base.code",
      "position": [
        20,
        220
      ]
    },
    {
      "id": "6834b314-dd66-429f-9264-6eba74c5984e",
      "name": "Sign PDF",
      "type": "n8n-nodes-base.code",
      "position": [
        20,
        380
      ]
    },
    {
      "id": "80e56344-b037-4c4f-8f18-b419e9c7516b",
      "name": "Prepare Success Response",
      "type": "n8n-nodes-base.set",
      "position": [
        1380,
        40
      ]
    },
    {
      "id": "e32d1e3e-6877-4c1f-b46a-0c3c67fba609",
      "name": "Switch Operation",
      "type": "n8n-nodes-base.switch",
      "position": [
        -520,
        200
      ]
    },
    {
      "id": "f28cb401-f180-4877-9440-aeb0c9f07791",
      "name": "Switch Upload Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        -100,
        -300
      ]
    },
    {
      "id": "5aa1d5f3-66d4-4440-a953-6e453d00b757",
      "name": "Prepare input params",
      "type": "n8n-nodes-base.set",
      "position": [
        -280,
        -300
      ]
    },
    {
      "id": "ae983277-f9cf-43b3-86ef-1135919f976c",
      "name": "set file path",
      "type": "n8n-nodes-base.set",
      "position": [
        -700,
        220
      ]
    },
    {
      "id": "2667149c-8d3b-4772-be8c-a01c1a8efa6f",
      "name": "Convert PDF to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        260,
        -440
      ]
    },
    {
      "id": "6559070f-e071-4e3a-ad3b-87911032358f",
      "name": "Write PDF File to Disk",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        440,
        -440
      ]
    },
    {
      "id": "0f6dfb44-8d83-4539-bec8-4aa4066c42bb",
      "name": "Read PDF File from Disk",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        620,
        -440
      ]
    },
    {
      "id": "59e18825-dd53-4b09-aefc-0c567ada7f1a",
      "name": "Convert PFX to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        260,
        -140
      ]
    },
    {
      "id": "d079d173-5c68-4b57-9efd-29a3ec89b6c0",
      "name": "Write PFX File to Disk",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        440,
        -140
      ]
    },
    {
      "id": "a2517543-fa29-4097-8f69-0c8cea6f9e07",
      "name": "Read PFX File from Disk",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        620,
        -140
      ]
    },
    {
      "id": "2ec5c8cd-c9f5-4008-988b-ab724b9d8a0f",
      "name": "Check PDF file is OK",
      "type": "n8n-nodes-base.set",
      "position": [
        800,
        -380
      ]
    },
    {
      "id": "2de3d4d5-6654-4019-b05a-2d1dc48c016f",
      "name": "Check PFX file is OK",
      "type": "n8n-nodes-base.set",
      "position": [
        800,
        -220
      ]
    },
    {
      "id": "5a2405a6-daef-4e57-8ab8-62dc9600cd26",
      "name": "check success",
      "type": "n8n-nodes-base.if",
      "position": [
        1180,
        180
      ]
    },
    {
      "id": "e7c2412e-eba2-4092-808f-808a27c2a64f",
      "name": "set downlowd file info",
      "type": "n8n-nodes-base.set",
      "position": [
        -220,
        740
      ]
    },
    {
      "id": "5710c64c-5edf-4de8-bb0a-dd9379c6ba1e",
      "name": "Read download file from Disk",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        0,
        740
      ]
    },
    {
      "id": "c6c8aea2-a770-4e32-94b5-c4b9f18ea3fe",
      "name": "API POST Endpoint",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -900,
        220
      ]
    },
    {
      "id": "c7387236-4d72-4123-b181-31059c7fb973",
      "name": "API GET Endpoint",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -900,
        560
      ]
    },
    {
      "id": "c87290be-95fd-4edf-8993-b0710714919b",
      "name": "POST Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1540,
        120
      ]
    },
    {
      "id": "501c7371-99a5-4d2f-bd54-ed8a9e8a67a9",
      "name": "POST Error Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1540,
        280
      ]
    },
    {
      "id": "3905360c-581c-4588-a509-7329e73a7ed6",
      "name": "GET Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        240,
        740
      ]
    },
    {
      "id": "088c46b6-0d52-4059-877c-bb38408b4c22",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        100
      ],
      "parameters": {
        "width": 740,
        "height": 440,
        "content": "# Cryptographic Operations\n## Generate Certificate and  Sign PDF"
      }
    },
    {
      "id": "6be21f42-4d11-4dc3-9d01-afed8afcde02",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        600
      ],
      "parameters": {
        "width": 740,
        "height": 320,
        "content": "# Document Management\n## Download document\n"
      }
    },
    {
      "id": "8972ffd2-ae7e-4999-ba31-242d23734498",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -560
      ],
      "parameters": {
        "width": 1380,
        "height": 620,
        "content": "# Document Management\n## Upload Certificate and Upload PDF\n"
      }
    },
    {
      "id": "262cfa68-f9bd-4145-9101-1bf3a3d2ea4a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        -80
      ],
      "parameters": {
        "width": 740,
        "height": 840,
        "content": "# Request Processing and Method Routing"
      }
    },
    {
      "id": "3d3620d6-4937-483d-a2e2-0a1089415a44",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        -100
      ],
      "parameters": {
        "width": 680,
        "height": 560,
        "content": "# Response Checking and Formatting"
      }
    }
  ],
  "connections": {
    "Sign PDF": {
      "main": [
        [
          {
            "node": "check success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Keys": {
      "main": [
        [
          {
            "node": "check success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "check success": {
      "main": [
        [
          {
            "node": "Prepare Success Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "POST Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set file path": {
      "main": [
        [
          {
            "node": "Switch Operation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "API GET Endpoint": {
      "main": [
        [
          {
            "node": "set file path",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Operation": {
      "main": [
        [
          {
            "node": "Prepare input params",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Validate Key Gen Params",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Validate PDF Sign Params",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "set downlowd file info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "API POST Endpoint": {
      "main": [
        [
          {
            "node": "set file path",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Upload Type": {
      "main": [
        [
          {
            "node": "Validate PDF Upload",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Validate Key Upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert PDF to File": {
      "main": [
        [
          {
            "node": "Write PDF File to Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert PFX to File": {
      "main": [
        [
          {
            "node": "Write PFX File to Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Key Upload": {
      "main": [
        [
          {
            "node": "Convert PFX to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate PDF Upload": {
      "main": [
        [
          {
            "node": "Convert PDF to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check PDF file is OK": {
      "main": [
        [
          {
            "node": "check success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check PFX file is OK": {
      "main": [
        [
          {
            "node": "check success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare input params": {
      "main": [
        [
          {
            "node": "Switch Upload Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GET Respond to Webhook": {
      "main": [
        []
      ]
    },
    "Write PDF File to Disk": {
      "main": [
        [
          {
            "node": "Read PDF File from Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write PFX File to Disk": {
      "main": [
        [
          {
            "node": "Read PFX File from Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set downlowd file info": {
      "main": [
        [
          {
            "node": "Read download file from Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read PDF File from Disk": {
      "main": [
        [
          {
            "node": "Check PDF file is OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read PFX File from Disk": {
      "main": [
        [
          {
            "node": "Check PFX file is OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Key Gen Params": {
      "main": [
        [
          {
            "node": "Generate Keys",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Success Response": {
      "main": [
        [
          {
            "node": "POST Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate PDF Sign Params": {
      "main": [
        [
          {
            "node": "Sign PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read download file from Disk": {
      "main": [
        [
          {
            "node": "GET Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}