{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "Projects",
      "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]+$"
        }
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "unsupportedMediaType": {
        "description": "不支持的媒体类型。"
      },
      "unprocessableEntity": {
        "description": "无法处理的实体"
      }
    }
  },
  "paths": {
    "/projects": {
      "post": {
        "operationId": "createProject",
        "tags": [
          "Projects"
        ],
        "summary": "创建项目",
        "description": "在实例中创建团队项目。",
        "parameters": [
          {
            "$ref": "#/components/parameters/idempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 36,
                    "description": "项目 ID。省略时，服务器会生成 ID。ID 已被使用时返回 HTTP 409。"
                  },
                  "icon": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "emoji",
                          "icon"
                        ]
                      },
                      "value": {
                        "type": "string",
                        "minLength": 1
                      },
                      "color": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "value"
                    ]
                  },
                  "description": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 512
                  },
                  "customTelemetryTags": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "key": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "key",
                        "value"
                      ]
                    }
                  },
                  "type": {
                    "type": "string",
                    "readOnly": true
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "readOnly": true
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "personal",
                        "team"
                      ],
                      "readOnly": true
                    },
                    "icon": {
                      "type": "object",
                      "description": "项目图标；项目没有图标时为 null",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "emoji",
                            "icon"
                          ]
                        },
                        "value": {
                          "type": "string"
                        },
                        "color": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "value"
                      ],
                      "nullable": true
                    },
                    "description": {
                      "type": "string",
                      "nullable": true
                    },
                    "customTelemetryTags": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "key",
                          "value"
                        ]
                      }
                    },
                    "creatorId": {
                      "type": "string",
                      "nullable": true
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "readOnly": true
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "readOnly": true
                    },
                    "role": {
                      "type": "string",
                      "description": "调用方在新项目中的角色。"
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "调用方在新项目中拥有的作用域。"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "type",
                    "icon",
                    "description",
                    "customTelemetryTags",
                    "creatorId",
                    "createdAt",
                    "updatedAt",
                    "role",
                    "scopes"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "409": {
            "description": "具有此 ID 的项目已存在。请求不会更改现有项目或其成员。"
          },
          "415": {
            "$ref": "#/components/responses/unsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/unprocessableEntity"
          }
        }
      }
    }
  }
}
