{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "SecurityPolicy",
      "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"
      }
    },
    "schemas": {
      "securityPolicyPublicDto.generated": {
        "type": "object",
        "properties": {
          "personalSpacePublishing": {
            "type": "boolean",
            "description": "成员是否可以从个人空间发布工作流和智能体。"
          },
          "personalSpaceSharing": {
            "type": "boolean",
            "description": "成员是否可以从个人空间共享工作流和凭据。"
          },
          "publishedPersonalWorkflowsCount": {
            "type": "integer",
            "description": "当前已发布的个人工作流数量，用于收紧策略前了解影响。",
            "readOnly": true
          },
          "sharedPersonalWorkflowsCount": {
            "type": "integer",
            "description": "当前与其他用户共享的个人工作流数量。",
            "readOnly": true
          },
          "sharedPersonalCredentialsCount": {
            "type": "integer",
            "description": "当前与其他用户共享的个人凭据数量。",
            "readOnly": true
          },
          "redactionEnforcement": {
            "type": "object",
            "properties": {
              "floor": {
                "type": "string",
                "enum": [
                  "off",
                  "production",
                  "all"
                ],
                "description": "在整个实例上强制执行的最低执行数据遮蔽级别。"
              }
            },
            "required": [
              "floor"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "personalSpacePublishing",
          "personalSpaceSharing",
          "publishedPersonalWorkflowsCount",
          "sharedPersonalWorkflowsCount",
          "sharedPersonalCredentialsCount",
          "redactionEnforcement"
        ],
        "additionalProperties": false
      }
    },
    "responses": {
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      }
    }
  },
  "paths": {
    "/settings/security-policy": {
      "get": {
        "operationId": "getSecurityPolicy",
        "tags": [
          "SecurityPolicy"
        ],
        "summary": "获取安全策略",
        "description": "获取实例安全策略，包括个人空间的发布与共享、执行数据遮蔽的最低强制级别，以及界面中显示的只读使用数量。需要 `securitySettings:manage` 作用域，并获得个人空间策略功能许可。",
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/securityPolicyPublicDto.generated"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          }
        }
      }
    }
  }
}
