{
  "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"
      }
    },
    "parameters": {
      "idempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "description": "此 POST 请求的安全重试键。使用 1 到 128 个可见 ASCII 字符。相同的键配合相同的请求，会返回首次成功的响应。使用此键发送不同请求时返回 422。首次请求仍在处理时重试，会返回 409。",
        "required": false,
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[\\x21-\\x7E]+$"
        }
      }
    },
    "schemas": {
      "promotePackageResultDto.generated": {
        "type": "object",
        "properties": {
          "environmentId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 36
          },
          "counts": {
            "type": "object",
            "properties": {
              "workflows": {
                "type": "integer",
                "minimum": 0
              },
              "folders": {
                "type": "integer",
                "minimum": 0
              },
              "credentials": {
                "type": "integer",
                "minimum": 0
              },
              "dataTables": {
                "type": "integer",
                "minimum": 0
              },
              "variables": {
                "type": "integer",
                "minimum": 0
              },
              "tags": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "workflows",
              "folders",
              "credentials",
              "dataTables",
              "variables",
              "tags"
            ]
          },
          "git": {
            "type": "object",
            "properties": {
              "commitSha": {
                "type": "string"
              },
              "branchName": {
                "type": "string"
              }
            },
            "required": [
              "commitSha",
              "branchName"
            ]
          },
          "review": {
            "type": "object",
            "properties": {
              "reviewId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 36
              },
              "number": {
                "type": "integer"
              },
              "webUrl": {
                "type": "string"
              }
            },
            "required": [
              "reviewId",
              "number",
              "webUrl"
            ]
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                },
                "linkUrl": {
                  "type": "string"
                }
              },
              "required": [
                "message"
              ]
            }
          }
        },
        "required": [
          "environmentId",
          "counts",
          "git"
        ]
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      },
      "conflict": {
        "description": "冲突"
      },
      "unsupportedMediaType": {
        "description": "不支持的媒体类型。"
      },
      "unprocessableEntity": {
        "description": "无法处理的实体"
      },
      "serviceUnavailable": {
        "description": "所请求的服务暂时不可用。"
      }
    }
  },
  "paths": {
    "/promotions/projects/{projectId}/promote": {
      "post": {
        "operationId": "promoteProjectSelection",
        "tags": [
          "Promotions"
        ],
        "summary": "晋升项目中所选工作流",
        "description": "将团队项目所选工作流晋升到项目 Promote 环境的分支。只发送工作流 id，服务器会即时读取每个工作流，因此推送携带当前状态。项目拥有的未归档和已归档工作流都会导出，已归档 id 在分支上仍保持归档；工作流已从实例消失的 id 会从分支移除，与项目变更列表一致。分支写入后移入或移出此项目的工作流会以 400 拒绝，请先移回。要删除的工作流如果不在分支的此项目下，会在任何写入前拒绝整个请求。需要为项目解析到 Promote 环境，优先使用项目自己的 Promote 环境，否则使用实例 Promote 环境，并且必须先连接。工作流引用变量时，API 密钥还需具备 variable:list。",
        "parameters": [
          {
            "$ref": "#/components/parameters/idempotencyKey"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "项目的 ID。",
            "name": "projectId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workflowIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 36
                    },
                    "minItems": 1
                  },
                  "commitMessage": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000,
                    "description": "晋升提交的消息；省略时使用自动生成的消息。"
                  }
                },
                "required": [
                  "workflowIds"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/promotePackageResultDto.generated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          },
          "409": {
            "$ref": "#/components/responses/conflict"
          },
          "415": {
            "$ref": "#/components/responses/unsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/unprocessableEntity"
          },
          "503": {
            "$ref": "#/components/responses/serviceUnavailable"
          }
        }
      }
    }
  }
}
