{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "Credential",
      "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": {
      "credentialPublicDto.generated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "isManaged": {
            "type": "boolean"
          },
          "isGlobal": {
            "type": "boolean"
          },
          "isResolvable": {
            "type": "boolean"
          },
          "resolvableAllowFallback": {
            "type": "boolean"
          },
          "resolverId": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "仅在启用凭据说明时返回。"
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "isManaged",
          "isGlobal",
          "isResolvable",
          "resolvableAllowFallback",
          "resolverId",
          "createdAt",
          "updatedAt"
        ]
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      },
      "unsupportedMediaType": {
        "description": "不支持的媒体类型。"
      }
    }
  },
  "paths": {
    "/credentials/{credentialId}": {
      "patch": {
        "operationId": "updateCredential",
        "tags": [
          "Credential"
        ],
        "summary": "按 ID 更新凭据",
        "description": "更新现有凭据。你必须是此凭据的所有者。",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "凭据的 ID。",
            "name": "credentialId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "凭据名称"
                  },
                  "description": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 512,
                    "description": "纯文本，最多 512 个字符。发送 null 或空白值可清除；省略则保留已存储的值。禁用凭据说明时忽略。"
                  },
                  "type": {
                    "type": "string",
                    "description": "凭据类型。更改类型时也必须提供 data。"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": {},
                    "description": "凭据数据。更改凭据类型时必填。字段也接受 n8n 表达式，即以 \"=\" 开头的字符串。",
                    "writeOnly": true
                  },
                  "isGlobal": {
                    "type": "boolean",
                    "description": "此凭据是否全局可用"
                  },
                  "isResolvable": {
                    "type": "boolean",
                    "description": "此凭据是否包含可解析字段"
                  },
                  "isPartialData": {
                    "type": "boolean",
                    "default": false,
                    "description": "为 true 时，取消现有凭据数据的遮蔽，并将其与提供的数据合并；为 false 时，替换整个 data 对象。"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/credentialPublicDto.generated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          },
          "415": {
            "$ref": "#/components/responses/unsupportedMediaType"
          }
        }
      }
    }
  }
}
