{
  "name": "AUT-204 Webhook امن سفارش (آزمایشی)",
  "nodes": [
    {
      "parameters": {
        "content": "## Webhook امن\n۱) احراز هویت Header Auth با Credential (توکن در ورک‌فلو نیست)\n۲) IP(s) Allowlist\n۳) سنجش payload پیش از هر اقدام\n۴) پاسخ صریح 202 یا 400",
        "height": 200,
        "width": 380,
        "color": 4
      },
      "id": "9b380fae-794b-58c9-9faa-968faf29ee91",
      "name": "یادداشت 1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -300
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "barg-sabz/orders",
        "authentication": "headerAuth",
        "responseMode": "responseNode",
        "options": {
          "ipWhitelist": "127.0.0.1,::1,::ffff:127.0.0.1"
        }
      },
      "id": "0cf59ce8-0d2b-552a-b8c9-7b68269b24d9",
      "name": "دریافت سفارش (Webhook)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        100
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "ecf60d554f395828",
          "name": "Barg Sabz webhook token (Header Auth)"
        }
      },
      "webhookId": "6b0f6f0e-2c1a-4d7e-9a51-a2040000beef"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "16aba806-85b2-59b2-8049-75f240cccbdf",
              "leftValue": "={{ $json.body.order_id }}",
              "rightValue": "^BS-[0-9]{4}$",
              "operator": {
                "type": "string",
                "operation": "regex"
              }
            },
            {
              "id": "1f8e3e36-fea5-5a95-bb14-ce4d2a7d4b9e",
              "leftValue": "={{ $json.body.event }}",
              "rightValue": "order.updated",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a32c6c70-d963-56ae-a0c3-d2d204769dd8",
      "name": "payload معتبر است؟",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        240,
        100
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"accepted\": true, \"order_id\": $json.body.order_id } }}",
        "options": {
          "responseCode": 202
        }
      },
      "id": "44c9fd83-c219-5614-bce8-e1b3a5d3a435",
      "name": "پاسخ 202",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        480,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "{ \"accepted\": false, \"error\": \"invalid payload\" }",
        "options": {
          "responseCode": 400
        }
      },
      "id": "667ea42a-fe20-5c85-954c-51345337b54d",
      "name": "پاسخ 400",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        480,
        200
      ]
    }
  ],
  "connections": {
    "دریافت سفارش (Webhook)": {
      "main": [
        [
          {
            "node": "payload معتبر است؟",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "payload معتبر است؟": {
      "main": [
        [
          {
            "node": "پاسخ 202",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "پاسخ 400",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "id": "LkyA204SecHook01",
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "lookiyar-academy-demo"
  },
  "tags": [
    {
      "name": "loOkiYar Academy"
    },
    {
      "name": "AUT-204"
    }
  ],
  "pinData": {}
}