Skip to content

网站接口 ​

本页给出网站生命周期接口。所有 :id 都是 API 返回的网站 ID;域名归属会在服务端再次校验。

查询列表 ​

http
GET /api/open/v1/sites?page=1&limit=20&search=example.com
Authorization: Bearer 你的API密钥

page 从 1 开始,limit 范围 1~100,search 按域名模糊搜索。响应中的 origins 会列出地址、权重和上游状态。

创建网站 ​

http
POST /api/open/v1/sites
Authorization: Bearer 你的API密钥
Content-Type: application/json
json
{
  "domain": "cdn.example.com,static.example.com",
  "packageId": "你的套餐ID",
  "origins": [
    {"address": "origin.example.com", "weight": 1},
    {"address": "203.0.113.10", "weight": 1}
  ],
  "originProtocol": "https",
  "httpPort": 80,
  "httpsPort": 443
}

规则:域名最多 20 个;支持 *.example.com;源站数量 1~10;权重 1~100;源站地址不能包含 http://、路径或空格;回源协议为 http、https 或 follow。

修改源站 ​

http
PATCH /api/open/v1/sites/网站ID/origin
Authorization: Bearer 你的API密钥
Content-Type: application/json

请求体与创建网站中的 origins、originProtocol、httpPort、httpsPort 相同。保存后建议先观察 5xx 和回源延迟,再进行缓存预热。

启用或停用 ​

json
{"enabled": false}

发送到 PATCH /api/open/v1/sites/网站ID/status。enabled: true 启用,false 停用。停用不会删除网站或证书关联。

删除网站 ​

http
DELETE /api/open/v1/sites/网站ID
Authorization: Bearer 你的API密钥
Content-Type: application/json
json
{"confirmDomain": "cdn.example.com"}

confirmDomain 必须与网站当前完整域名一致;多域名网站请按接口返回的 domain 原样确认。删除前请先切换 DNS,并确认不再需要证书和安全策略。

缓存任务 ​

http
POST /api/open/v1/cache/tasks
Authorization: Bearer 你的API密钥
Content-Type: application/json
json
{
  "type": "purge",
  "urls": [
    "https://cdn.example.com/assets/app.css",
    "https://cdn.example.com/images/logo.png"
  ]
}

type 可选 purge(按 URL 刷新)、purge-directory(目录刷新)或 preheat(预热)。URL 必须是完整 HTTP(S) 地址、数量 1~100,且主机名属于当前账号的网站。

基于 VitePress 构建