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

添加一个或多个证书

POST/v1/certs

创建一个或多个证书记录;请求体可以是单个 JSON 对象,也可以是对象数组,数组中的全部证书在同一个数据库事务中处理。普通用户证书归属于当前账号,管理员可以通过 uid 指定所属用户。custom 表示上传已有证书和私钥,lets、zerossl、buypass 表示自动签发;自动签发证书创建后会立即建立签发任务。任一证书校验失败时整个批次回滚,不会保留已插入的部分记录。

身份认证

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

单个证书创建对象。普通创建至少需要 name;证书类型及其条件字段由服务端按上述规则校验。

字段类型必填说明与约束
uidinteger (int64)可选

证书所属用户 ID;省略时使用当前登录用户,仅管理员可指定,否则返回 cert-48。

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

证书显示名称;服务端会过滤可执行的 HTML,处理后不得为空,同一所属用户下不可重复,并只保存处理后前 200 个字符。创建时必填。

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

证书备注;服务端会过滤可执行的 HTML,省略时保存为空字符串。

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

证书类型:custom 为上传证书,lets 为 Let's Encrypt,zerossl 为 ZeroSSL,buypass 为 BuyPass。省略时读取全局或用户证书默认配置。

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

自动签发所使用的 DNS API 配置 ID;可显式传 null 表示不使用,非空时必须是已存在的 DNS API。通配符自动证书必须指定非空 DNS API。省略时读取用户默认配置。

展开字段结构

自动签发所使用的 DNS API 配置 ID;可显式传 null 表示不使用,非空时必须是已存在的 DNS API。通配符自动证书必须指定非空 DNS API。省略时读取用户默认配置。

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

自动签发证书的域名,类型为 lets、zerossl 或 buypass 时必填并会转为小写;通配符域名还必须配合 DNS API。custom 类型不会采用该字段,而是从证书的 SAN/CN 中解析域名。

keystring (password)可选

上传证书的私钥 PEM;custom 类型必填,服务端会去除首尾空白、校验末尾 PEM 分隔符并验证与证书匹配。其他类型通常省略。示例不得填入真实私钥。

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

上传证书链 PEM;custom 类型必填,服务端会解析每个证书并验证有效性。其他类型通常省略。示例不得填入真实证书内容。

约束 / 默认值 / 示例
{
  "writeOnly": true
}
oneOf · 2 · array <object>

批量证书创建对象数组;数组可以为空,空数组会提交一个不含证书的空批次并返回空数据字符串。数组中任一对象校验失败时整批回滚。

数组元素 · object

单个证书创建对象。普通创建至少需要 name;证书类型及其条件字段由服务端按上述规则校验。

字段类型必填说明与约束
uidinteger (int64)可选

证书所属用户 ID;省略时使用当前登录用户,仅管理员可指定,否则返回 cert-48。

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

证书显示名称;服务端会过滤可执行的 HTML,处理后不得为空,同一所属用户下不可重复,并只保存处理后前 200 个字符。创建时必填。

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

证书备注;服务端会过滤可执行的 HTML,省略时保存为空字符串。

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

证书类型:custom 为上传证书,lets 为 Let's Encrypt,zerossl 为 ZeroSSL,buypass 为 BuyPass。省略时读取全局或用户证书默认配置。

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

自动签发所使用的 DNS API 配置 ID;可显式传 null 表示不使用,非空时必须是已存在的 DNS API。通配符自动证书必须指定非空 DNS API。省略时读取用户默认配置。

展开字段结构

自动签发所使用的 DNS API 配置 ID;可显式传 null 表示不使用,非空时必须是已存在的 DNS API。通配符自动证书必须指定非空 DNS API。省略时读取用户默认配置。

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

自动签发证书的域名,类型为 lets、zerossl 或 buypass 时必填并会转为小写;通配符域名还必须配合 DNS API。custom 类型不会采用该字段,而是从证书的 SAN/CN 中解析域名。

keystring (password)可选

上传证书的私钥 PEM;custom 类型必填,服务端会去除首尾空白、校验末尾 PEM 分隔符并验证与证书匹配。其他类型通常省略。示例不得填入真实私钥。

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

上传证书链 PEM;custom 类型必填,服务端会解析每个证书并验证有效性。其他类型通常省略。示例不得填入真实证书内容。

约束 / 默认值 / 示例
{
  "writeOnly": true
}
完整 Schema
{
  "oneOf": [
    {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "uid": {
          "type": "integer",
          "format": "int64",
          "minimum": 1,
          "description": "证书所属用户 ID;省略时使用当前登录用户,仅管理员可指定,否则返回 `cert-48`。"
        },
        "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` 为上传证书,`lets` 为 Let's Encrypt,`zerossl` 为 ZeroSSL,`buypass` 为 BuyPass。省略时读取全局或用户证书默认配置。"
        },
        "dnsapi": {
          "oneOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            {
              "type": "string",
              "nullable": true,
              "enum": [
                null
              ]
            }
          ],
          "description": "自动签发所使用的 DNS API 配置 ID;可显式传 null 表示不使用,非空时必须是已存在的 DNS API。通配符自动证书必须指定非空 DNS API。省略时读取用户默认配置。"
        },
        "domain": {
          "type": "string",
          "description": "自动签发证书的域名,类型为 `lets`、`zerossl` 或 `buypass` 时必填并会转为小写;通配符域名还必须配合 DNS API。`custom` 类型不会采用该字段,而是从证书的 SAN/CN 中解析域名。"
        },
        "key": {
          "type": "string",
          "format": "password",
          "writeOnly": true,
          "description": "上传证书的私钥 PEM;`custom` 类型必填,服务端会去除首尾空白、校验末尾 PEM 分隔符并验证与证书匹配。其他类型通常省略。示例不得填入真实私钥。"
        },
        "cert": {
          "type": "string",
          "writeOnly": true,
          "description": "上传证书链 PEM;`custom` 类型必填,服务端会解析每个证书并验证有效性。其他类型通常省略。示例不得填入真实证书内容。"
        }
      },
      "additionalProperties": true,
      "description": "单个证书创建对象。普通创建至少需要 `name`;证书类型及其条件字段由服务端按上述规则校验。"
    },
    {
      "type": "array",
      "minItems": 0,
      "description": "批量证书创建对象数组;数组可以为空,空数组会提交一个不含证书的空批次并返回空数据字符串。数组中任一对象校验失败时整批回滚。",
      "items": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "uid": {
            "type": "integer",
            "format": "int64",
            "minimum": 1,
            "description": "证书所属用户 ID;省略时使用当前登录用户,仅管理员可指定,否则返回 `cert-48`。"
          },
          "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` 为上传证书,`lets` 为 Let's Encrypt,`zerossl` 为 ZeroSSL,`buypass` 为 BuyPass。省略时读取全局或用户证书默认配置。"
          },
          "dnsapi": {
            "oneOf": [
              {
                "type": "integer",
                "minimum": 1
              },
              {
                "type": "string",
                "pattern": "^[0-9]+$"
              },
              {
                "type": "string",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ],
            "description": "自动签发所使用的 DNS API 配置 ID;可显式传 null 表示不使用,非空时必须是已存在的 DNS API。通配符自动证书必须指定非空 DNS API。省略时读取用户默认配置。"
          },
          "domain": {
            "type": "string",
            "description": "自动签发证书的域名,类型为 `lets`、`zerossl` 或 `buypass` 时必填并会转为小写;通配符域名还必须配合 DNS API。`custom` 类型不会采用该字段,而是从证书的 SAN/CN 中解析域名。"
          },
          "key": {
            "type": "string",
            "format": "password",
            "writeOnly": true,
            "description": "上传证书的私钥 PEM;`custom` 类型必填,服务端会去除首尾空白、校验末尾 PEM 分隔符并验证与证书匹配。其他类型通常省略。示例不得填入真实私钥。"
          },
          "cert": {
            "type": "string",
            "writeOnly": true,
            "description": "上传证书链 PEM;`custom` 类型必填,服务端会解析每个证书并验证有效性。其他类型通常省略。示例不得填入真实证书内容。"
          }
        },
        "additionalProperties": true,
        "description": "单个证书创建对象。普通创建至少需要 `name`;证书类型及其条件字段由服务端按上述规则校验。"
      }
    }
  ]
}

示例

{
  "name": "API 自动证书",
  "des": "生产站点证书",
  "type": "lets",
  "domain": "api.example.invalid",
  "dnsapi": 12
}

请求体示例

{
  "uid": 0,
  "name": "string",
  "des": "string",
  "type": "custom",
  "dnsapi": 0,
  "domain": "string",
  "key": "string",
  "cert": "string"
}

响应

HTTP 200

业务结果通过 HTTP 200 返回。全部证书校验并提交后返回创建结果;配额、套餐、名称、类型、DNS API、域名、PEM、管理员归属、证书有效性、参数状态、兼容性更新字段、系统维护或认证校验失败时返回字符串业务错误码,整个批次事务回滚。

application/json

oneOf

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

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

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

证书创建批次成功后返回的确认消息。

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

正常创建时为新证书 ID 的英文逗号分隔字符串;空数组时为空字符串。若兼容性地传入 id 触发更新逻辑,内容可能是更新差异 JSON 字符串。

oneOf · 2 · object
字段类型必填说明与约束
codestring必填

业务错误码:6、7 表示兼容性 ID 格式错误或记录不存在;8、23 表示证书数量超限或普通用户未购买有效套餐;9、11、12 表示名称为空、重复或缺失;14、15 表示证书类型为空或无效;17、18 表示 DNS API 格式错误或不存在;19、21、22 表示自动证书域名为空、通配符缺少 DNS API 或域名未提供;25、26、27、28、29、40、41、43、46 表示私钥/证书缺失、格式、解析、匹配或域名提取失败;30、31、42、45 表示启用、自动续签或强制禁用参数无效;32 表示证书仍被网站使用且未强制禁用;38、39 表示重新签发仅支持已有自动证书或不能在创建时使用;48、49 表示管理员专属归属字段或目标证书权限不足;maintain 表示当前禁止写操作,login_required 表示认证无效。

约束 / 默认值 / 示例
{
  "enum": [
    "cert-6",
    "cert-7",
    "cert-8",
    "cert-9",
    "cert-11",
    "cert-12",
    "cert-14",
    "cert-15",
    "cert-17",
    "cert-18",
    "cert-19",
    "cert-21",
    "cert-22",
    "cert-23",
    "cert-25",
    "cert-26",
    "cert-27",
    "cert-28",
    "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"
  ]
}
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",
          "description": "正常创建时为新证书 ID 的英文逗号分隔字符串;空数组时为空字符串。若兼容性地传入 `id` 触发更新逻辑,内容可能是更新差异 JSON 字符串。"
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "cert-6",
            "cert-7",
            "cert-8",
            "cert-9",
            "cert-11",
            "cert-12",
            "cert-14",
            "cert-15",
            "cert-17",
            "cert-18",
            "cert-19",
            "cert-21",
            "cert-22",
            "cert-23",
            "cert-25",
            "cert-26",
            "cert-27",
            "cert-28",
            "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": "业务错误码:6、7 表示兼容性 ID 格式错误或记录不存在;8、23 表示证书数量超限或普通用户未购买有效套餐;9、11、12 表示名称为空、重复或缺失;14、15 表示证书类型为空或无效;17、18 表示 DNS API 格式错误或不存在;19、21、22 表示自动证书域名为空、通配符缺少 DNS API 或域名未提供;25、26、27、28、29、40、41、43、46 表示私钥/证书缺失、格式、解析、匹配或域名提取失败;30、31、42、45 表示启用、自动续签或强制禁用参数无效;32 表示证书仍被网站使用且未强制禁用;38、39 表示重新签发仅支持已有自动证书或不能在创建时使用;48、49 表示管理员专属归属字段或目标证书权限不足;`maintain` 表示当前禁止写操作,`login_required` 表示认证无效。"
        },
        "msg": {
          "type": "string",
          "description": "与业务错误码对应的中文配额、套餐、字段、证书材料、权限、任务状态、维护状态或认证失败原因。"
        },
        "data": {
          "type": "string",
          "enum": [
            ""
          ],
          "description": "业务错误时固定为空字符串。"
        }
      },
      "additionalProperties": false
    }
  ]
}

示例

{
  "code": 0,
  "msg": "证书添加成功",
  "data": "10021,10022"
}

cURL 示例

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

curl --request POST \
  "https://master.example.invalid/v1/certs" \
  --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"}'

查看完整接口 JSON