更新指定证书
/v1/certs/{cert_id}按路径证书 ID 更新一条证书。请求体必须是 JSON 对象,路径 ID 会覆盖请求体中可能存在的 id;单条接口不接受数组。名称、备注、类型、DNS API、域名、证书材料、启用/续签和重新签发字段均可按需提供,未提供字段保持原值。普通用户只能更新自己的证书,管理员可更新其他用户证书;任一校验失败返回 HTTP 200 业务错误。
身份认证
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 同时发送。"
}
}请求参数
| 参数 | 位置 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|---|
cert_id | path | integer (int64) | 必填 | 要更新的证书 ID;路由只接受十进制整数,并覆盖请求体中的 id。 完整参数定义 |
请求体 · 必填
application/json
object
指定证书的部分更新对象;路径 ID 为唯一目标。
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
uid | integer (int64) | 可选 | 兼容性所属用户上下文,仅管理员可传;不会转移证书。 约束 / 默认值 / 示例 |
name | string | 可选 | 新的证书名称;过滤 HTML、检查同用户唯一并保存前 200 个字符,省略时保持原值。 约束 / 默认值 / 示例 |
des | string | 可选 | 新的证书备注,可传空字符串清空,省略时保持原值。 约束 / 默认值 / 示例 |
type | string | 可选 | 新的证书类型;自动类型切换会建立签发任务,省略时保持原类型。 约束 / 默认值 / 示例 |
dnsapi | oneOf | 可选 | 新的 DNS API ID;非空时必须存在,null 清除,省略时保持原值。 展开字段结构新的 DNS API ID;非空时必须存在,null 清除,省略时保持原值。 oneOf · 1 · integeroneOf · 2 · stringoneOf · 3 · string |
domain | string | 可选 | 自动证书的新域名;自动类型下转小写并触发签发,通配符需 DNS API,custom 类型从 PEM SAN/CN 解析。 |
key | string (password) | 可选 | custom 类型的新私钥 PEM;校验格式和证书匹配,示例不得使用真实私钥。 约束 / 默认值 / 示例 |
cert | string | 可选 | custom 类型的新证书链 PEM;校验解析,示例不得使用真实证书。 约束 / 默认值 / 示例 |
force_disable | integer | 可选 | 禁用在用证书的强制标志;0 返回 cert-32,1 同时关闭关联网站 HTTPS 并同步。 约束 / 默认值 / 示例 |
auto_renew | integer | 可选 | 自动续签状态,1 启用、0 关闭,省略时保持原值。 约束 / 默认值 / 示例 |
enable | integer | 可选 | 证书启用状态,1 启用、0 禁用;禁用会创建证书删除任务。 约束 / 默认值 / 示例 |
reissue | oneOf | 可选 | 字段存在即重新签发;目标必须是 lets、zerossl 或 buypass 自动证书。 展开字段结构字段存在即重新签发;目标必须是 lets、zerossl 或 buypass 自动证书。 oneOf · 1 · booleanoneOf · 2 · integer |
完整 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 为唯一目标。"
}示例
{
"auto_renew": 1,
"enable": 1
}请求体示例
{
"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 返回。更新成功返回确认消息;对象格式、证书记录、字段、证书材料、网站引用、权限、任务和认证校验失败返回业务错误码。
application/json
oneOf
oneOf · 1 · object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | integer | 必填 | 更新成功状态码,固定为 0。 约束 / 默认值 / 示例 |
msg | string | 必填 | 证书更新成功消息。 约束 / 默认值 / 示例 |
data | string | 必填 | 更新成功时固定为 null。 约束 / 默认值 / 示例 |
oneOf · 2 · object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | string | 必填 | 业务错误码: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 | string | 必填 | 与业务错误码对应的中文字段、权限、任务或认证失败原因。 |
data | string | 必填 | 业务错误时固定为空字符串。 约束 / 默认值 / 示例 |
完整 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
}
]
}示例
{
"code": 0,
"msg": "更新证书成功",
"data": null
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request PUT \
"https://master.example.invalid/v1/certs/{cert_id}" \
--header "access-token: YOUR_ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"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}'