Skip to content
Console

S4 certificate API

List the certificates in the Certificate Center, fetch a certificate and its private key, or upload an existing certificate.

Best practice: call Get certificate content on a schedule from your own infrastructure and pair it with a deployment script to roll out the latest domain certificates everywhere automatically. For the full script, see Deploy certificates.

Authentication

Every endpoint is authenticated with the Authorization request header, whose value is your console API token (no Bearer prefix). Get one at Console › API Token.

curl -H "Authorization: <API Token>" "https://api.bitiful.com/..."

An API token can access the resources in your account, and it can read the private keys of all certificates. Use it on the server only, and never put it in frontend code or a public repository.

Base URL

https://api.bitiful.com

Responses and errors

Every endpoint returns JSON. On success the status code is 200, and submit-type endpoints return {"message":"ok"}. On failure the matching status code is returned, with the reason in message:

{ "message": "鉴权失败" }
Status codeExample messageDescription
401鉴权失败 (authentication failed)Authorization wasn't sent, or the API token is invalid.
403参数不合法 (invalid parameter)A parameter is missing, or the JSON is malformed.
403异常错误 (unexpected error)When fetching certificate content: the certificate name doesn't exist, or the certificate has no content yet (being requested, or the request failed).
403证书内容无效或不是PEM格式 (the certificate content is invalid or not PEM)The uploaded cert_content isn't a valid PEM certificate.
403证书与私钥不匹配或私钥格式错误 (the certificate and private key don't match, or the private key format is wrong)The private key doesn't match the certificate, is password-protected, or contains extra content.
403存在同名证书,请更换证书名 (a certificate with the same name exists, change the name)The uploaded name is already in use.
403您的账号已欠费,暂时无法访问该接口 (your account is overdue, this endpoint is temporarily unavailable)You can't upload certificates while your balance is overdue.
500证书部署失败 (certificate deployment failed), 发生错误,请稍后重试 (an error occurred, try again later), and so onServer error. Try again later.

Examples

curl -H "Authorization: <API Token>" "https://api.bitiful.com/cert/list"
curl -fsS -H "Authorization: <API Token>" \
  "https://api.bitiful.com/cert/data/my-cert/content" -o cert.json

jq -er .crt cert.json > fullchain.pem
(umask 077 && jq -er .key cert.json > private.key)
jq -n --arg name "my-domain-cert" \
  --rawfile crt fullchain.pem --rawfile key private.key \
  '{cert_name: $name, cert_content: $crt, cert_private_key: $key}' |
curl -X POST "https://api.bitiful.com/cert/add" \
  -H "Authorization: <API Token>" \
  -H "Content-Type: application/json" \
  --data-binary @-

证书管理

GET证书列表/cert/list
GET获取证书内容/cert/data/{cert_name}/content
POST上传证书/cert/add