{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "Promotions",
      "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": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      },
      "serviceUnavailable": {
        "description": "所请求的服务暂时不可用。"
      }
    }
  },
  "paths": {
    "/promotions/projects/{projectId}/changes/{direction}": {
      "get": {
        "operationId": "getPromotionChanges",
        "tags": [
          "Promotions"
        ],
        "summary": "列出项目在某个方向上的变更",
        "description": "比较实例上的团队项目与该方向晋升环境的分支，列出不同的工作流。对于 `promote`，各行表示晋升将发送到分支的内容，密钥需要 gitConnection:push 作用域。`deleted` 或 `new` 的晋升行可能表示跨项目移动的工作流，在移回之前会拒绝晋升。对于 `apply`，各行表示将分支应用到此实例所产生的变更，密钥需要 gitConnection:pull 作用域。`commitSha` 是读取这些行时使用的提交。需要先连接环境。",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "项目的 ID。",
            "name": "projectId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "apply",
                "promote"
              ]
            },
            "required": true,
            "description": "晋升方向：apply 或 promote。",
            "name": "direction",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "name",
                "updatedAt",
                "status"
              ],
              "default": "name"
            },
            "required": false,
            "name": "sort",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "required": false,
            "name": "order",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "commitSha": {
                      "type": "string",
                      "nullable": true
                    },
                    "source": {
                      "type": "object",
                      "properties": {
                        "environmentId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 36
                        },
                        "branchName": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "environmentId",
                        "branchName"
                      ]
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 36
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "workflow"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "new",
                              "modified",
                              "renamed",
                              "renamed-and-modified",
                              "archived",
                              "deleted"
                            ]
                          },
                          "version": {
                            "type": "integer",
                            "nullable": true,
                            "minimum": 0
                          },
                          "updatedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "updatedBy": {
                            "type": "string",
                            "nullable": true
                          },
                          "dependencyCount": {
                            "type": "integer",
                            "minimum": 0
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "type",
                          "status",
                          "version",
                          "updatedAt",
                          "updatedBy",
                          "dependencyCount"
                        ]
                      }
                    }
                  },
                  "required": [
                    "commitSha",
                    "source",
                    "changes"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          },
          "503": {
            "$ref": "#/components/responses/serviceUnavailable"
          }
        }
      }
    }
  }
}
