{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "LogStreaming",
      "description": "日志流目标相关操作"
    }
  ],
  "servers": [
    {
      "url": "/api/v1",
      "description": "当前 n8n 实例（自托管版本的内置测试台）"
    },
    {
      "url": "{url}/api/v1",
      "description": "自托管 n8n 实例",
      "variables": {
        "url": {
          "default": "https://example.com"
        }
      }
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "BearerAuth": []
    },
    {
      "CookieAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-N8N-API-KEY"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "CookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "n8n-auth"
      }
    },
    "responses": {
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      }
    }
  },
  "paths": {
    "/settings/log-streaming/destinations": {
      "get": {
        "operationId": "getLogStreamingDestinations",
        "tags": [
          "LogStreaming"
        ],
        "summary": "列出日志流目标",
        "description": "列出已配置的日志流目标。需要 `eventBusDestination:list` 作用域，并获得日志流功能许可。",
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "description": "界面中显示的可读名称。"
                              },
                              "enabled": {
                                "type": "boolean",
                                "description": "目标当前是否接收事件。"
                              },
                              "subscribedEvents": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "description": "此目标接收的事件名称或事件组前缀，例如 `n8n.workflow` 会匹配所有 `n8n.workflow.*` 事件。可从 `GET /settings/log-streaming/event-types` 获取完整的可传输事件名称列表。"
                              },
                              "anonymizeAuditMessages": {
                                "type": "boolean",
                                "description": "发送审计消息负载之前，是否进行匿名化。"
                              },
                              "circuitBreaker": {
                                "type": "object",
                                "properties": {
                                  "maxFailures": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true,
                                    "description": "熔断器断开前，滑动窗口内允许的最大失败次数。"
                                  },
                                  "failureWindow": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true,
                                    "description": "统计失败次数的滑动窗口，单位为毫秒。"
                                  }
                                },
                                "description": "投递熔断器的调节配置。反复失败后，目标会在冷却窗口内停止发送，避免持续请求异常的接收端。所有字段均可选，省略时使用合理的默认值。"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "webhook"
                                ],
                                "description": "将每个事件作为 HTTP 请求发送到 URL。"
                              },
                              "url": {
                                "type": "string",
                                "format": "uri",
                                "description": "接收事件负载的目标 URL。"
                              },
                              "method": {
                                "type": "string",
                                "description": "请求使用的 HTTP 方法。"
                              },
                              "sendHeaders": {
                                "type": "boolean",
                                "description": "是否为请求附加自定义请求头。"
                              },
                              "specifyHeaders": {
                                "type": "string",
                                "description": "自定义请求头的提供方式：`keypair` 或 `json`。"
                              },
                              "headerParameters": {
                                "type": "object",
                                "properties": {
                                  "parameters": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "value": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "boolean"
                                            },
                                            {},
                                            {}
                                          ],
                                          "description": "参数值，通常为字符串，也接受数字、布尔值和 null。"
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "value"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "parameters"
                                ],
                                "description": "相应的 `specify*` 字段为 `keypair` 时使用的键值对。"
                              },
                              "jsonHeaders": {
                                "type": "string",
                                "description": "`specifyHeaders` 为 `json` 时，以 JSON 字符串提供的自定义请求头。"
                              },
                              "sendQuery": {
                                "type": "boolean",
                                "description": "是否为请求附加查询参数。"
                              },
                              "specifyQuery": {
                                "type": "string",
                                "description": "查询参数的提供方式：`keypair` 或 `json`。"
                              },
                              "queryParameters": {
                                "type": "object",
                                "properties": {
                                  "parameters": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "value": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "boolean"
                                            },
                                            {},
                                            {}
                                          ],
                                          "description": "参数值，通常为字符串，也接受数字、布尔值和 null。"
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "value"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "parameters"
                                ],
                                "description": "相应的 `specify*` 字段为 `keypair` 时使用的键值对。"
                              },
                              "jsonQuery": {
                                "type": "string",
                                "description": "`specifyQuery` 为 `json` 时，以 JSON 字符串提供的查询参数。"
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "timeout": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true,
                                    "description": "请求超时时长，单位为毫秒。"
                                  },
                                  "allowUnauthorizedCerts": {
                                    "type": "boolean",
                                    "description": "接受自签名或其他无效的 TLS 证书。"
                                  },
                                  "queryParameterArrays": {
                                    "type": "string",
                                    "enum": [
                                      "indices",
                                      "brackets",
                                      "repeat"
                                    ],
                                    "description": "如何将数组值查询参数序列化到查询字符串中。"
                                  },
                                  "redirect": {
                                    "type": "object",
                                    "properties": {
                                      "redirect": {
                                        "type": "object",
                                        "properties": {
                                          "followRedirects": {
                                            "type": "boolean",
                                            "description": "是否跟随 HTTP 重定向。"
                                          },
                                          "maxRedirects": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "exclusiveMinimum": true,
                                            "description": "最多跟随的重定向次数。"
                                          }
                                        }
                                      }
                                    },
                                    "required": [
                                      "redirect"
                                    ],
                                    "description": "跟随重定向的行为。"
                                  },
                                  "proxy": {
                                    "type": "object",
                                    "properties": {
                                      "proxy": {
                                        "type": "object",
                                        "properties": {
                                          "protocol": {
                                            "type": "string",
                                            "enum": [
                                              "https",
                                              "http"
                                            ],
                                            "description": "代理协议。"
                                          },
                                          "host": {
                                            "type": "string",
                                            "description": "代理主机，不包含协议或端口。"
                                          },
                                          "port": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "exclusiveMinimum": true,
                                            "description": "代理端口。"
                                          }
                                        },
                                        "required": [
                                          "protocol",
                                          "host",
                                          "port"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "proxy"
                                    ],
                                    "description": "出站代理配置。"
                                  },
                                  "socket": {
                                    "type": "object",
                                    "properties": {
                                      "keepAlive": {
                                        "type": "boolean",
                                        "description": "是否保持套接字打开以便复用。"
                                      },
                                      "maxSockets": {
                                        "type": "integer",
                                        "minimum": 0,
                                        "exclusiveMinimum": true,
                                        "description": "每个主机同时保持打开的最大套接字数。"
                                      },
                                      "maxFreeSockets": {
                                        "type": "integer",
                                        "minimum": 0,
                                        "exclusiveMinimum": true,
                                        "description": "每个主机保持打开的最大空闲套接字数。"
                                      }
                                    },
                                    "description": "连接套接字选项。"
                                  }
                                },
                                "description": "附加 HTTP 请求选项。"
                              },
                              "id": {
                                "type": "string",
                                "description": "服务器生成的目标唯一 id，响应中返回，请求中不接受。"
                              }
                            },
                            "required": [
                              "type",
                              "url",
                              "id"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "description": "界面中显示的可读名称。"
                              },
                              "enabled": {
                                "type": "boolean",
                                "description": "目标当前是否接收事件。"
                              },
                              "subscribedEvents": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "description": "此目标接收的事件名称或事件组前缀，例如 `n8n.workflow` 会匹配所有 `n8n.workflow.*` 事件。可从 `GET /settings/log-streaming/event-types` 获取完整的可传输事件名称列表。"
                              },
                              "anonymizeAuditMessages": {
                                "type": "boolean",
                                "description": "发送审计消息负载之前，是否进行匿名化。"
                              },
                              "circuitBreaker": {
                                "type": "object",
                                "properties": {
                                  "maxFailures": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true,
                                    "description": "熔断器断开前，滑动窗口内允许的最大失败次数。"
                                  },
                                  "failureWindow": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true,
                                    "description": "统计失败次数的滑动窗口，单位为毫秒。"
                                  }
                                },
                                "description": "投递熔断器的调节配置。反复失败后，目标会在冷却窗口内停止发送，避免持续请求异常的接收端。所有字段均可选，省略时使用合理的默认值。"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "syslog"
                                ],
                                "description": "将每个事件发送到 syslog 服务器。"
                              },
                              "host": {
                                "type": "string",
                                "minLength": 1,
                                "description": "Syslog 服务器主机。"
                              },
                              "port": {
                                "type": "integer",
                                "minimum": 0,
                                "exclusiveMinimum": true,
                                "description": "Syslog 服务器端口。"
                              },
                              "protocol": {
                                "type": "string",
                                "enum": [
                                  "udp",
                                  "tcp",
                                  "tls"
                                ],
                                "description": "传输协议。"
                              },
                              "facility": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "Syslog facility 代码（0–23，按 RFC 5424）。常用值：0 Kernel（内核）、1 User（用户）、3 System（系统）、13 Audit（审计）、14 Alert（警报）、16 Local0、17 Local1、18 Local2、19 Local3、20 Local4、21 Local5、22 Local6、23 Local7。"
                              },
                              "app_name": {
                                "type": "string",
                                "description": "syslog 消息中报告的应用名称。"
                              },
                              "tlsCa": {
                                "type": "string",
                                "description": "`protocol` 为 `tls` 时使用的 PEM 编码 CA 证书。"
                              },
                              "id": {
                                "type": "string",
                                "description": "服务器生成的目标唯一 id，响应中返回，请求中不接受。"
                              }
                            },
                            "required": [
                              "type",
                              "host",
                              "id"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "description": "界面中显示的可读名称。"
                              },
                              "enabled": {
                                "type": "boolean",
                                "description": "目标当前是否接收事件。"
                              },
                              "subscribedEvents": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "description": "此目标接收的事件名称或事件组前缀，例如 `n8n.workflow` 会匹配所有 `n8n.workflow.*` 事件。可从 `GET /settings/log-streaming/event-types` 获取完整的可传输事件名称列表。"
                              },
                              "anonymizeAuditMessages": {
                                "type": "boolean",
                                "description": "发送审计消息负载之前，是否进行匿名化。"
                              },
                              "circuitBreaker": {
                                "type": "object",
                                "properties": {
                                  "maxFailures": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true,
                                    "description": "熔断器断开前，滑动窗口内允许的最大失败次数。"
                                  },
                                  "failureWindow": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true,
                                    "description": "统计失败次数的滑动窗口，单位为毫秒。"
                                  }
                                },
                                "description": "投递熔断器的调节配置。反复失败后，目标会在冷却窗口内停止发送，避免持续请求异常的接收端。所有字段均可选，省略时使用合理的默认值。"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "sentry"
                                ],
                                "description": "将每个事件发送到 Sentry 项目。"
                              },
                              "dsn": {
                                "type": "string",
                                "format": "uri",
                                "description": "接收事件的 Sentry DSN。"
                              },
                              "id": {
                                "type": "string",
                                "description": "服务器生成的目标唯一 id，响应中返回，请求中不接受。"
                              }
                            },
                            "required": [
                              "type",
                              "dsn",
                              "id"
                            ]
                          }
                        ],
                        "description": "日志流目标。`type` 字段选择变体及其特定字段：`webhook`、`syslog` 或 `sentry`。",
                        "type": "object"
                      },
                      "description": "已配置的日志流目标。"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          }
        }
      }
    }
  }
}
