{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "User",
      "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": "禁止访问"
      }
    }
  },
  "paths": {
    "/users/{userId}": {
      "get": {
        "operationId": "getUser",
        "tags": [
          "User"
        ],
        "summary": "按 ID／邮箱获取用户",
        "description": "获取实例中的某个用户，仅实例所有者可用。",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "用户的 ID 或邮箱。",
            "name": "userId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "false"
            },
            "required": false,
            "name": "includeRole",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "readOnly": true
                    },
                    "email": {
                      "type": "string",
                      "nullable": true,
                      "format": "email"
                    },
                    "firstName": {
                      "type": "string",
                      "nullable": true,
                      "readOnly": true
                    },
                    "lastName": {
                      "type": "string",
                      "nullable": true,
                      "readOnly": true
                    },
                    "isPending": {
                      "type": "boolean",
                      "description": "用户是否已响应邀请并完成账户设置：已完成为 true，未完成为 false。",
                      "readOnly": true
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "readOnly": true
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "readOnly": true
                    },
                    "mfaEnabled": {
                      "type": "boolean",
                      "description": "用户是否启用了多重身份验证（MFA/2FA）。",
                      "readOnly": true
                    },
                    "role": {
                      "type": "string",
                      "readOnly": true
                    }
                  },
                  "required": [
                    "id",
                    "email",
                    "firstName",
                    "lastName",
                    "isPending",
                    "createdAt",
                    "updatedAt",
                    "mfaEnabled"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "description": "没有具有该 ID 或邮箱的用户。"
          }
        }
      }
    }
  }
}
