{
  "tags": [
    "证书管理"
  ],
  "description": "按路径证书 ID 更新一条证书。请求体必须是 JSON 对象，路径 ID 会覆盖请求体中可能存在的 id；单条接口不接受数组。名称、备注、类型、DNS API、域名、证书材料、启用/续签和重新签发字段均可按需提供，未提供字段保持原值。普通用户只能更新自己的证书，管理员可更新其他用户证书；任一校验失败返回 HTTP 200 业务错误。",
  "operationId": "user_put_v1_certs_cert_id",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "业务结果通过 HTTP 200 返回。更新成功返回确认消息；对象格式、证书记录、字段、证书材料、网站引用、权限、任务和认证校验失败返回业务错误码。",
      "content": {
        "application/json": {
          "schema": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "integer",
                    "enum": [
                      0
                    ],
                    "description": "更新成功状态码，固定为 0。"
                  },
                  "msg": {
                    "type": "string",
                    "enum": [
                      "更新证书成功"
                    ],
                    "description": "证书更新成功消息。"
                  },
                  "data": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      null
                    ],
                    "description": "更新成功时固定为 null。"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "cert-5",
                      "cert-6",
                      "cert-7",
                      "cert-9",
                      "cert-11",
                      "cert-14",
                      "cert-15",
                      "cert-17",
                      "cert-18",
                      "cert-19",
                      "cert-21",
                      "cert-25",
                      "cert-27",
                      "cert-29",
                      "cert-30",
                      "cert-31",
                      "cert-32",
                      "cert-38",
                      "cert-39",
                      "cert-40",
                      "cert-41",
                      "cert-42",
                      "cert-43",
                      "cert-45",
                      "cert-46",
                      "cert-48",
                      "cert-49",
                      "maintain",
                      "login_required"
                    ],
                    "description": "业务错误码：5 表示请求体不是对象；6、7 表示 ID 格式错误或证书不存在；9、11、14、15、17、18、19、21 表示名称、类型、DNS API 或域名校验失败；25、27、29、40、41、43、46 表示证书材料、匹配、解析或域名提取失败；30、31、32 表示启用状态或在用证书限制；38、39 表示重新签发限制；42、45 表示续签或强制禁用参数无效；48、49 表示管理员字段或目标权限不足；maintain 和 login_required 表示维护或认证失败。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "与业务错误码对应的中文字段、权限、任务或认证失败原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "业务错误时固定为空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "example": {
            "code": 0,
            "msg": "更新证书成功",
            "data": null
          }
        }
      }
    }
  },
  "x-python-handler": "site.CertAPI",
  "x-python-route-line": 363,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "cert_id",
      "in": "path",
      "required": true,
      "description": "要更新的证书 ID；路由只接受十进制整数，并覆盖请求体中的 id。",
      "schema": {
        "type": "integer",
        "format": "int64",
        "minimum": 1
      },
      "example": 10021
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "uid": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "description": "兼容性所属用户上下文，仅管理员可传；不会转移证书。"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "description": "新的证书名称；过滤 HTML、检查同用户唯一并保存前 200 个字符，省略时保持原值。"
            },
            "des": {
              "type": "string",
              "maxLength": 255,
              "description": "新的证书备注，可传空字符串清空，省略时保持原值。"
            },
            "type": {
              "type": "string",
              "enum": [
                "custom",
                "lets",
                "zerossl",
                "buypass"
              ],
              "description": "新的证书类型；自动类型切换会建立签发任务，省略时保持原类型。"
            },
            "dnsapi": {
              "oneOf": [
                {
                  "type": "integer",
                  "minimum": 1
                },
                {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                },
                {
                  "type": "string",
                  "nullable": true,
                  "enum": [
                    null
                  ]
                }
              ],
              "description": "新的 DNS API ID；非空时必须存在，null 清除，省略时保持原值。"
            },
            "domain": {
              "type": "string",
              "description": "自动证书的新域名；自动类型下转小写并触发签发，通配符需 DNS API，custom 类型从 PEM SAN/CN 解析。"
            },
            "key": {
              "type": "string",
              "format": "password",
              "writeOnly": true,
              "description": "custom 类型的新私钥 PEM；校验格式和证书匹配，示例不得使用真实私钥。"
            },
            "cert": {
              "type": "string",
              "writeOnly": true,
              "description": "custom 类型的新证书链 PEM；校验解析，示例不得使用真实证书。"
            },
            "force_disable": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "description": "禁用在用证书的强制标志；0 返回 cert-32，1 同时关闭关联网站 HTTPS 并同步。"
            },
            "auto_renew": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "description": "自动续签状态，1 启用、0 关闭，省略时保持原值。"
            },
            "enable": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "description": "证书启用状态，1 启用、0 禁用；禁用会创建证书删除任务。"
            },
            "reissue": {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "integer",
                  "enum": [
                    0,
                    1
                  ]
                }
              ],
              "description": "字段存在即重新签发；目标必须是 lets、zerossl 或 buypass 自动证书。"
            }
          },
          "additionalProperties": true,
          "description": "指定证书的部分更新对象；路径 ID 为唯一目标。"
        },
        "example": {
          "auto_renew": 1,
          "enable": 1
        }
      }
    }
  },
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "site.CertAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 363
    },
    {
      "key": "x-audience",
      "value": "user"
    },
    {
      "key": "x-auth",
      "value": "user"
    },
    {
      "key": "x-reviewed",
      "value": true
    },
    {
      "key": "x-itecdn-source-reviewed",
      "value": true
    }
  ],
  "method": "put",
  "path": "/v1/certs/{cert_id}",
  "servers": [
    {
      "url": "https://master.example.invalid",
      "description": "不可调用的示例地址；复制示例后替换为自己的主控域名。"
    }
  ],
  "securitySchemes": {
    "AccessToken": {
      "type": "apiKey",
      "in": "header",
      "name": "access-token",
      "description": "通过登录接口获得的短期访问令牌。"
    },
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "api-key",
      "description": "API Key；必须和 api-secret 同时发送。"
    },
    "ApiSecret": {
      "type": "apiKey",
      "in": "header",
      "name": "api-secret",
      "description": "API Secret；必须和 api-key 同时发送。"
    }
  },
  "jsonRequestBodyExample": {
    "uid": 0,
    "name": "string",
    "des": "string",
    "type": "custom",
    "dnsapi": 0,
    "domain": "string",
    "key": "string",
    "cert": "string",
    "force_disable": 0,
    "auto_renew": 0,
    "enable": 0,
    "reissue": true
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "更新指定证书",
    "description": {
      "content": "按路径证书 ID 更新一条证书。请求体必须是 JSON 对象，路径 ID 会覆盖请求体中可能存在的 id；单条接口不接受数组。名称、备注、类型、DNS API、域名、证书材料、启用/续签和重新签发字段均可按需提供，未提供字段保持原值。普通用户只能更新自己的证书，管理员可更新其他用户证书；任一校验失败返回 HTTP 200 业务错误。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "certs",
        ":cert_id"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [],
      "variable": [
        {
          "disabled": false,
          "description": {
            "content": "(Required) 要更新的证书 ID；路由只接受十进制整数，并覆盖请求体中的 id。",
            "type": "text/plain"
          },
          "type": "any",
          "value": "",
          "key": "cert_id"
        }
      ]
    },
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "PUT",
    "body": {
      "mode": "raw",
      "raw": "",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "type": "any",
          "value": "access-token",
          "key": "key"
        },
        {
          "type": "any",
          "value": "{{apiKey}}",
          "key": "value"
        },
        {
          "type": "any",
          "value": "header",
          "key": "in"
        }
      ]
    }
  }
}