{
  "openapi": "3.1.0",
  "info": {
    "title": "Flocks Workflow Webhook API",
    "version": "fa86a422",
    "description": "外部事件投递入口。认证模式和自定义头名称由触发器配置决定，本规范列默认名称。"
  },
  "paths": {
    "/webhook/workflows/{workflow_id}/{trigger_id}": {
      "post": {
        "operationId": "deliverWorkflowWebhook",
        "parameters": [
          {
            "name": "workflow_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "trigger_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-flocks-delivery-id",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "可选投递 ID；处理时截取前200字符。还支持文档列明的三个备用请求头。"
          }
        ],
        "security": [
          {
            "WebhookApiKey": []
          },
          {
            "WebhookQueryKey": []
          },
          {
            "WebhookHmac": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {}
            },
            "text/plain": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "响应",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "duplicate": {
                      "type": "boolean"
                    },
                    "matched": {
                      "type": "boolean"
                    },
                    "executed": {
                      "type": "boolean"
                    },
                    "inputs": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "deliveryId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "ok",
                    "duplicate",
                    "matched",
                    "executed",
                    "inputs",
                    "deliveryId"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "响应",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {}
                  },
                  "required": [
                    "error",
                    "message"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "响应",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {}
                  },
                  "required": [
                    "error",
                    "message"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "响应",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {}
                  },
                  "required": [
                    "error",
                    "message"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "响应",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {}
                  },
                  "required": [
                    "error",
                    "message"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "响应",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {}
                  },
                  "required": [
                    "error",
                    "message"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "核心全局门禁不可用；返回体取决于门禁分支",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "WebhookApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      },
      "WebhookQueryKey": {
        "type": "apiKey",
        "in": "query",
        "name": "api_key"
      },
      "WebhookHmac": {
        "type": "apiKey",
        "in": "header",
        "name": "x-flocks-signature",
        "description": "HMAC-SHA256(raw body)，纯hex或sha256=hex。不是直接发送Secret。"
      }
    }
  }
}
