{
  "tags": [
    "证书管理"
  ],
  "description": "在一个数据库事务中更新一个或多个证书；请求体可以是单个对象或对象数组，服务端会将单对象包装成数组处理。每个更新对象必须带证书 id，任一对象不存在、越权或校验失败时整批回滚。支持修改名称、备注、类型、DNS API、域名、证书材料、启用/续签状态和重新签发；自动证书变化可能创建签发及同步任务，禁用正在使用的证书时可用 force_disable=1 同时关闭关联网站 HTTPS 并创建网站同步任务。",
  "operationId": "user_put_v1_certs",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "业务结果通过 HTTP 200 返回。全部证书更新并提交后返回确认消息；请求体格式、目标证书、名称、类型、DNS API、域名、PEM、权限、启用/续签、重新签发、网站引用、系统维护或认证校验失败时返回字符串业务错误码，整个批次事务回滚。",
      "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-36",
                      "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 表示 DNS API 格式错误或不存在；19、21 表示自动证书域名为空或通配符缺少 DNS API；25、27、29、40、41、43、46 表示私钥或证书缺失、格式、匹配、解析或域名提取失败；30、31 表示启用状态无效；32 表示证书仍被网站使用且未强制禁用；36 表示批量请求不是数组；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": 362,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "oneOf": [
            {
              "type": "object",
              "required": [
                "id"
              ],
              "properties": {
                "id": {
                  "oneOf": [
                    {
                      "type": "integer",
                      "minimum": 1
                    },
                    {
                      "type": "string",
                      "pattern": "^[0-9]+$"
                    }
                  ],
                  "description": "要更新的证书 ID；必须是数字或数字字符串，记录必须存在，跨用户更新需要管理员身份。"
                },
                "uid": {
                  "type": "integer",
                  "format": "int64",
                  "minimum": 1,
                  "description": "兼容性所属用户上下文字段；仅管理员可传，用于校验目标证书所属用户，不会转移证书。"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 255,
                  "description": "新的证书名称；服务端过滤 HTML、校验同一用户下唯一，并保存处理后前 200 个字符，省略时保持原值。"
                },
                "des": {
                  "type": "string",
                  "maxLength": 255,
                  "description": "新的证书备注；服务端过滤 HTML，可传空字符串清空备注，省略时保持原值。"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "custom",
                    "lets",
                    "zerossl",
                    "buypass"
                  ],
                  "description": "新的证书类型；由 custom 切换到自动类型会创建签发任务，由自动类型切换为 custom 会结束旧签发任务，省略时保持原类型。"
                },
                "dnsapi": {
                  "oneOf": [
                    {
                      "type": "integer",
                      "minimum": 1
                    },
                    {
                      "type": "string",
                      "pattern": "^[0-9]+$"
                    },
                    {
                      "type": "string",
                      "nullable": true,
                      "enum": [
                        null
                      ]
                    }
                  ],
                  "description": "新的 DNS API 配置 ID；非空时必须对应已有 DNS API，传 null 可清除，省略时保持原值。"
                },
                "domain": {
                  "type": "string",
                  "description": "自动证书的新域名；自动类型下转为小写并触发重新签发，通配符必须指定 DNS API，省略时保持原值。custom 类型会从上传证书 SAN/CN 重新解析。"
                },
                "key": {
                  "type": "string",
                  "format": "password",
                  "writeOnly": true,
                  "description": "新的自上传证书私钥 PEM；仅 custom 类型校验末尾格式和证书匹配，内容变化且证书在使用时创建同步任务。示例不得使用真实私钥。"
                },
                "cert": {
                  "type": "string",
                  "writeOnly": true,
                  "description": "新的自上传证书链 PEM；仅 custom 类型解析并校验证书，内容变化且证书在使用时可能创建同步任务。示例不得使用真实证书。"
                },
                "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": "单个证书更新对象；未提供的字段沿用当前记录。"
            },
            {
              "type": "array",
              "minItems": 1,
              "description": "批量证书更新对象数组；每项都必须包含 id，任一项失败时整批回滚。",
              "items": {
                "type": "object",
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "oneOf": [
                      {
                        "type": "integer",
                        "minimum": 1
                      },
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$"
                      }
                    ],
                    "description": "要更新的证书 ID；必须是数字或数字字符串，记录必须存在，跨用户更新需要管理员身份。"
                  },
                  "uid": {
                    "type": "integer",
                    "format": "int64",
                    "minimum": 1,
                    "description": "兼容性所属用户上下文字段；仅管理员可传，用于校验目标证书所属用户，不会转移证书。"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255,
                    "description": "新的证书名称；服务端过滤 HTML、校验同一用户下唯一，并保存处理后前 200 个字符，省略时保持原值。"
                  },
                  "des": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "新的证书备注；服务端过滤 HTML，可传空字符串清空备注，省略时保持原值。"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "custom",
                      "lets",
                      "zerossl",
                      "buypass"
                    ],
                    "description": "新的证书类型；由 custom 切换到自动类型会创建签发任务，由自动类型切换为 custom 会结束旧签发任务，省略时保持原类型。"
                  },
                  "dnsapi": {
                    "oneOf": [
                      {
                        "type": "integer",
                        "minimum": 1
                      },
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$"
                      },
                      {
                        "type": "string",
                        "nullable": true,
                        "enum": [
                          null
                        ]
                      }
                    ],
                    "description": "新的 DNS API 配置 ID；非空时必须对应已有 DNS API，传 null 可清除，省略时保持原值。"
                  },
                  "domain": {
                    "type": "string",
                    "description": "自动证书的新域名；自动类型下转为小写并触发重新签发，通配符必须指定 DNS API，省略时保持原值。custom 类型会从上传证书 SAN/CN 重新解析。"
                  },
                  "key": {
                    "type": "string",
                    "format": "password",
                    "writeOnly": true,
                    "description": "新的自上传证书私钥 PEM；仅 custom 类型校验末尾格式和证书匹配，内容变化且证书在使用时创建同步任务。示例不得使用真实私钥。"
                  },
                  "cert": {
                    "type": "string",
                    "writeOnly": true,
                    "description": "新的自上传证书链 PEM；仅 custom 类型解析并校验证书，内容变化且证书在使用时可能创建同步任务。示例不得使用真实证书。"
                  },
                  "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": "单个证书更新对象；未提供的字段沿用当前记录。"
              }
            }
          ]
        },
        "example": [
          {
            "id": 10021,
            "auto_renew": 1,
            "enable": 1
          },
          {
            "id": 10022,
            "reissue": true
          }
        ]
      }
    }
  },
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "site.CertAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 362
    },
    {
      "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",
  "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": {
    "id": 0,
    "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，任一对象不存在、越权或校验失败时整批回滚。支持修改名称、备注、类型、DNS API、域名、证书材料、启用/续签状态和重新签发；自动证书变化可能创建签发及同步任务，禁用正在使用的证书时可用 force_disable=1 同时关闭关联网站 HTTPS 并创建网站同步任务。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "certs"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [],
      "variable": []
    },
    "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"
        }
      ]
    }
  }
}