{
  "name": "DocuFlow Universal Extraction",
  "nodes": [
    {
      "parameters": {},
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "={{ $json.source_url }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "source_url",
              "value": "={{ $json.source_url }}"
            },
            {
              "name": "target_schema",
              "value": "={{ JSON.stringify($json.target_schema) }}"
            },
            {
              "name": "use_gpu_ocr",
              "value": "={{ $json.use_gpu_ocr || false }}"
            }
          ]
        },
        "options": {
          "timeout": 120000,
          "batching": {
            "batch": {
              "batchSize": 1
            }
          }
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "id": "b2c3d4e5-f6g7-8901-bcde-f23456789012",
      "name": "DocuFlow API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        500,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "type": "boolean"
          },
          "conditions": [
            {
              "id": "d4e5f6g7-h8i9-0123-defg-456789012345",
              "leftValue": "={{ $json.status }}",
              "rightValue": "success",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ]
        }
      },
      "id": "c3d4e5f6-g7h8-9012-cdef-345678901234",
      "name": "Success Check",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        750,
        300
      ]
    },
    {
      "parameters": {
        "operation": "format",
        "srcFieldName": "data",
        "targetFieldName": "extracted_data",
        "changes": {
          "toString": [],
          "toNumber": [],
          "toBoolean": [],
          "toDate": []
        }
      },
      "id": "d4e5f6g7-h8i9-0123-defg-456789012345",
      "name": "Format Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1000,
        200
      ]
    },
    {
      "parameters": {
        "operation": "format",
        "srcFieldName": "error",
        "targetFieldName": "error_message",
        "changes": {
          "toString": []
        }
      },
      "id": "e5f6g7h8-i9j0-1234-efgh-567890123456",
      "name": "Format Error",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1000,
        400
      ]
    },
    {
      "parameters": {
        "operation": "merge",
        "mergeBy": "index",
        "options": {}
      },
      "id": "f6g7h8i9-j0k1-2345-fghi-678901234567",
      "name": "Merge Results",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2,
      "position": [
        1250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "format",
        "srcFieldName": "extracted_data",
        "targetFieldName": "final_output",
        "changes": {
          "toString": []
        }
      },
      "id": "g7h8i9j0-k1l2-3456-ghij-789012345678",
      "name": "Final Output",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1500,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "DocuFlow API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DocuFlow API": {
      "main": [
        [
          {
            "node": "Success Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Success Check": {
      "main": [
        [
          {
            "node": "Format Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Data": {
      "main": [
        [
          {
            "node": "Merge Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Error": {
      "main": [
        [
          {
            "node": "Merge Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge Results": {
      "main": [
        [
          {
            "node": "Final Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1.0.0",
  "meta": {
    "templateCredsSetupByName": {
      "DocuFlow API Key": {
        "name": "HTTP Header Auth",
        "id": "docuflow-api-key"
      }
    }
  },
  "id": "docuflow-universal-extraction-template",
  "tags": [
    "pdf",
    "ocr",
    "extraction",
    "ai",
    "automation"
  ]
}