itecdn 5.x用户文档
itecdn 5.x / 用户 API

批量更新证书

PUT/v1/certs

在一个数据库事务中更新一个或多个证书;请求体可以是单个对象或对象数组,服务端会将单对象包装成数组处理。每个更新对象必须带证书 id,任一对象不存在、越权或校验失败时整批回滚。支持修改名称、备注、类型、DNS API、域名、证书材料、启用/续签状态和重新签发;自动证书变化可能创建签发及同步任务,禁用正在使用的证书时可用 force_disable=1 同时关闭关联网站 HTTPS 并创建网站同步任务。

身份认证

access-token

api-key + api-secret

认证定义
{
  "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 同时发送。"
  }
}

请求参数

未定义路径、查询或请求头参数。

请求体 · 必填

application/json

oneOf

oneOf · 1 · object

单个证书更新对象;未提供的字段沿用当前记录。

字段类型必填说明与约束
idoneOf必填

要更新的证书 ID;必须是数字或数字字符串,记录必须存在,跨用户更新需要管理员身份。

展开字段结构

要更新的证书 ID;必须是数字或数字字符串,记录必须存在,跨用户更新需要管理员身份。

oneOf · 1 · integer
oneOf · 2 · string
uidinteger (int64)可选

兼容性所属用户上下文字段;仅管理员可传,用于校验目标证书所属用户,不会转移证书。

约束 / 默认值 / 示例
{
  "format": "int64",
  "minimum": 1
}
namestring可选

新的证书名称;服务端过滤 HTML、校验同一用户下唯一,并保存处理后前 200 个字符,省略时保持原值。

约束 / 默认值 / 示例
{
  "minLength": 1,
  "maxLength": 255
}
desstring可选

新的证书备注;服务端过滤 HTML,可传空字符串清空备注,省略时保持原值。

约束 / 默认值 / 示例
{
  "maxLength": 255
}
typestring可选

新的证书类型;由 custom 切换到自动类型会创建签发任务,由自动类型切换为 custom 会结束旧签发任务,省略时保持原类型。

约束 / 默认值 / 示例
{
  "enum": [
    "custom",
    "lets",
    "zerossl",
    "buypass"
  ]
}
dnsapioneOf可选

新的 DNS API 配置 ID;非空时必须对应已有 DNS API,传 null 可清除,省略时保持原值。

展开字段结构

新的 DNS API 配置 ID;非空时必须对应已有 DNS API,传 null 可清除,省略时保持原值。

oneOf · 1 · integer
oneOf · 2 · string
oneOf · 3 · string
domainstring可选

自动证书的新域名;自动类型下转为小写并触发重新签发,通配符必须指定 DNS API,省略时保持原值。custom 类型会从上传证书 SAN/CN 重新解析。

keystring (password)可选

新的自上传证书私钥 PEM;仅 custom 类型校验末尾格式和证书匹配,内容变化且证书在使用时创建同步任务。示例不得使用真实私钥。

约束 / 默认值 / 示例
{
  "format": "password",
  "writeOnly": true
}
certstring可选

新的自上传证书链 PEM;仅 custom 类型解析并校验证书,内容变化且证书在使用时可能创建同步任务。示例不得使用真实证书。

约束 / 默认值 / 示例
{
  "writeOnly": true
}
force_disableinteger可选

禁用正在被网站使用的证书时的强制标志:0 返回 cert-32,1 清空关联网站 HTTPS 配置并创建网站同步任务。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
auto_renewinteger可选

自动续签状态:1 启用,0 关闭;省略时保持原值。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
enableinteger可选

证书启用状态:1 启用,0 禁用;禁用会创建证书删除任务,省略时保持原值。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
reissueoneOf可选

重新签发开关;字段存在即触发重新签发,目标必须是 lets、zerossl 或 buypass 类型。

展开字段结构

重新签发开关;字段存在即触发重新签发,目标必须是 lets、zerossl 或 buypass 类型。

oneOf · 1 · boolean
oneOf · 2 · integer
oneOf · 2 · array <object>

批量证书更新对象数组;每项都必须包含 id,任一项失败时整批回滚。

数组元素 · object

单个证书更新对象;未提供的字段沿用当前记录。

字段类型必填说明与约束
idoneOf必填

要更新的证书 ID;必须是数字或数字字符串,记录必须存在,跨用户更新需要管理员身份。

展开字段结构

要更新的证书 ID;必须是数字或数字字符串,记录必须存在,跨用户更新需要管理员身份。

oneOf · 1 · integer
oneOf · 2 · string
uidinteger (int64)可选

兼容性所属用户上下文字段;仅管理员可传,用于校验目标证书所属用户,不会转移证书。

约束 / 默认值 / 示例
{
  "format": "int64",
  "minimum": 1
}
namestring可选

新的证书名称;服务端过滤 HTML、校验同一用户下唯一,并保存处理后前 200 个字符,省略时保持原值。

约束 / 默认值 / 示例
{
  "minLength": 1,
  "maxLength": 255
}
desstring可选

新的证书备注;服务端过滤 HTML,可传空字符串清空备注,省略时保持原值。

约束 / 默认值 / 示例
{
  "maxLength": 255
}
typestring可选

新的证书类型;由 custom 切换到自动类型会创建签发任务,由自动类型切换为 custom 会结束旧签发任务,省略时保持原类型。

约束 / 默认值 / 示例
{
  "enum": [
    "custom",
    "lets",
    "zerossl",
    "buypass"
  ]
}
dnsapioneOf可选

新的 DNS API 配置 ID;非空时必须对应已有 DNS API,传 null 可清除,省略时保持原值。

展开字段结构

新的 DNS API 配置 ID;非空时必须对应已有 DNS API,传 null 可清除,省略时保持原值。

oneOf · 1 · integer
oneOf · 2 · string
oneOf · 3 · string
domainstring可选

自动证书的新域名;自动类型下转为小写并触发重新签发,通配符必须指定 DNS API,省略时保持原值。custom 类型会从上传证书 SAN/CN 重新解析。

keystring (password)可选

新的自上传证书私钥 PEM;仅 custom 类型校验末尾格式和证书匹配,内容变化且证书在使用时创建同步任务。示例不得使用真实私钥。

约束 / 默认值 / 示例
{
  "format": "password",
  "writeOnly": true
}
certstring可选

新的自上传证书链 PEM;仅 custom 类型解析并校验证书,内容变化且证书在使用时可能创建同步任务。示例不得使用真实证书。

约束 / 默认值 / 示例
{
  "writeOnly": true
}
force_disableinteger可选

禁用正在被网站使用的证书时的强制标志:0 返回 cert-32,1 清空关联网站 HTTPS 配置并创建网站同步任务。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
auto_renewinteger可选

自动续签状态:1 启用,0 关闭;省略时保持原值。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
enableinteger可选

证书启用状态:1 启用,0 禁用;禁用会创建证书删除任务,省略时保持原值。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
reissueoneOf可选

重新签发开关;字段存在即触发重新签发,目标必须是 lets、zerossl 或 buypass 类型。

展开字段结构

重新签发开关;字段存在即触发重新签发,目标必须是 lets、zerossl 或 buypass 类型。

oneOf · 1 · boolean
oneOf · 2 · integer
完整 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": "单个证书更新对象;未提供的字段沿用当前记录。"
      }
    }
  ]
}

示例

[
  {
    "id": 10021,
    "auto_renew": 1,
    "enable": 1
  },
  {
    "id": 10022,
    "reissue": true
  }
]

请求体示例

{
  "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
}

响应

HTTP 200

业务结果通过 HTTP 200 返回。全部证书更新并提交后返回确认消息;请求体格式、目标证书、名称、类型、DNS API、域名、PEM、权限、启用/续签、重新签发、网站引用、系统维护或认证校验失败时返回字符串业务错误码,整个批次事务回滚。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

成功状态码,所有证书更新并提交后固定为 0。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
msgstring必填

证书更新批次成功后返回的确认消息。

约束 / 默认值 / 示例
{
  "enum": [
    "更新证书成功"
  ]
}
datastring必填

更新成功时没有额外业务数据,固定为 null。

约束 / 默认值 / 示例
{
  "nullable": true,
  "enum": [
    null
  ]
}
oneOf · 2 · object
字段类型必填说明与约束
codestring必填

业务错误码: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 表示认证无效。

约束 / 默认值 / 示例
{
  "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"
  ]
}
msgstring必填

与业务错误码对应的中文请求格式、目标记录、字段、证书材料、网站引用、权限、维护状态或认证失败原因。

datastring必填

业务错误时固定为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 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
    }
  ]
}

示例

{
  "code": 0,
  "msg": "更新证书成功",
  "data": null
}

cURL 示例

根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。

curl --request PUT \
  "https://master.example.invalid/v1/certs" \
  --header "access-token: YOUR_ACCESS_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{"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}'

查看完整接口 JSON