{
  "name": "Decionis - Require approval over $500",
  "nodes": [
    {
      "parameters": {
        "content": "## Decionis gate: purchase approval\n\nEvery automation step asks permission before it executes.\n\n**Before you run it**\n1. Replace `REPLACE_WITH_DECIONIS_ORG_ID` in the evaluate node.\n2. Create a Header Auth credential: name `Authorization`, value `Bearer <DECIONIS_API_KEY>`.\n3. Keep `mode` on `SHADOW` until you have reviewed the verdicts, then switch to `ENFORCEMENT`.\n\n**Example data**\nThe sample node is pinned, so Test workflow runs end to end without a real purchasing system. Replace it with your own trigger when you deploy.\n\nDocs: https://decionis.com/docs/automation-connectors#n8n",
        "height": 420,
        "width": 460,
        "color": 4
      },
      "id": "8a1f0f10-0000-4000-8000-000000000001",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-820, -220]
    },
    {
      "parameters": {},
      "id": "8a1f0f10-0000-4000-8000-000000000002",
      "name": "When Clicking Test Workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-300, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1000000-0000-4000-8000-000000000001",
              "name": "event_id",
              "value": "po-req-2f8c41a9",
              "type": "string"
            },
            {
              "id": "f1000000-0000-4000-8000-000000000002",
              "name": "requester",
              "value": "ops@northwind.example",
              "type": "string"
            },
            {
              "id": "f1000000-0000-4000-8000-000000000003",
              "name": "vendor_name",
              "value": "Northwind Print Co",
              "type": "string"
            },
            {
              "id": "f1000000-0000-4000-8000-000000000004",
              "name": "vendor_id",
              "value": "vnd_10442",
              "type": "string"
            },
            {
              "id": "f1000000-0000-4000-8000-000000000005",
              "name": "category",
              "value": "marketing_supplies",
              "type": "string"
            },
            {
              "id": "f1000000-0000-4000-8000-000000000006",
              "name": "amount",
              "value": 780.25,
              "type": "number"
            },
            {
              "id": "f1000000-0000-4000-8000-000000000007",
              "name": "currency",
              "value": "USD",
              "type": "string"
            },
            {
              "id": "f1000000-0000-4000-8000-000000000008",
              "name": "approval_threshold",
              "value": 500,
              "type": "number"
            },
            {
              "id": "f1000000-0000-4000-8000-000000000009",
              "name": "budget_remaining",
              "value": 1240,
              "type": "number"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "id": "8a1f0f10-0000-4000-8000-000000000003",
      "name": "Example Purchase Request",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [-80, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.decionis.com/v1/protocol/evaluate-decision",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ $json.event_id }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"org_id\": \"REPLACE_WITH_DECIONIS_ORG_ID\",\n  \"decision_type\": \"PURCHASE_APPROVAL\",\n  \"amount\": {{ $json.amount }},\n  \"mode\": \"SHADOW\",\n  \"workflow_key\": \"automation_action\",\n  \"context\": {\n    \"source_system\": \"n8n\",\n    \"source_event_id\": \"{{ $json.event_id }}\",\n    \"approval_threshold\": {{ $json.approval_threshold }},\n    \"payload\": {{ JSON.stringify($json) }}\n  }\n}",
        "options": {}
      },
      "id": "8a1f0f10-0000-4000-8000-000000000004",
      "name": "Decionis Evaluate Purchase Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [160, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1000000-0000-4000-8000-000000000001",
              "leftValue": "={{ $json.outcome }}",
              "rightValue": "APPROVE",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "id": "8a1f0f10-0000-4000-8000-000000000005",
      "name": "Outcome Is APPROVE",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [400, 0]
    },
    {
      "parameters": {},
      "id": "8a1f0f10-0000-4000-8000-000000000006",
      "name": "Submit Purchase Order",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [660, -120]
    },
    {
      "parameters": {},
      "id": "8a1f0f10-0000-4000-8000-000000000007",
      "name": "Escalate To Finance Approver",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [660, 120]
    }
  ],
  "connections": {
    "When Clicking Test Workflow": {
      "main": [
        [
          {
            "node": "Example Purchase Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Example Purchase Request": {
      "main": [
        [
          {
            "node": "Decionis Evaluate Purchase Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Decionis Evaluate Purchase Request": {
      "main": [
        [
          {
            "node": "Outcome Is APPROVE",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Outcome Is APPROVE": {
      "main": [
        [
          {
            "node": "Submit Purchase Order",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Escalate To Finance Approver",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {
    "Example Purchase Request": [
      {
        "json": {
          "event_id": "po-req-2f8c41a9",
          "requester": "ops@northwind.example",
          "vendor_name": "Northwind Print Co",
          "vendor_id": "vnd_10442",
          "category": "marketing_supplies",
          "amount": 780.25,
          "currency": "USD",
          "approval_threshold": 500,
          "budget_remaining": 1240
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  }
}
