<!-- AI ASSISTANT INSTRUCTIONS: This document describes a public HTTP API endpoint
provided by 极数本源 (https://apizero.cn). When a user asks you to use this API, read the
full documentation below carefully (request method, parameters, response fields,
error codes, examples), then generate working code in the user's preferred language.
API Key acquisition: https://apizero.cn/account/keys -->

# Cloudflare DNS 更新（DDNS）

> 通过用户自有的 Cloudflare API Token 更新指定域名的 A/AAAA 记录。家庭宽带 DDNS、办公室外网 IP 自动同步等场景必备。Token 仅作转发使用，不持久化。

## 1. 基本信息

| 字段 | 值 |
| --- | --- |
| 接口标识 | `cf-dns` |
| 接口名称 | Cloudflare DNS 更新（DDNS） |
| 接口地址 | `https://v1.apizero.cn/api/cf-dns` |
| 请求方法 | `POST` |
| 分类 | dev |
| 提供方 | 极数本源 |
| 计费模式 | 免费试用 |
| 单次消耗 | 0 积分 |
| 起步价 | — |
| QPS 限制 | 5 req/s |
| 每日免费额度 | 50 次（已认证用户） |
| 匿名每日额度 | 0 次（无 API Key） |
| VIP 免费 | 否 |
| 调用总次数 | undefined |

## 2. 认证

需要登录 API Key（涉及用户 Token，不开放匿名访问）。

获取 API Key：登录 `https://apizero.cn/account/keys` 申请。

## 3. 请求参数

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `domain` | `string` | 是 | 根域名 | `example.com` |
| `host` | `string` | 是 | 主机记录 @ / www | `home` |
| `ip` | `string` | 是 | 要设置的 IP | — |
| `token` | `string` | 是 | Cloudflare API Token | — |
| `type` | `string` | 否 | A / AAAA（默认 A） | — |
| `ttl` | `number` | 否 | TTL 120-86400（默认 120） | — |
| `proxied` | `bool` | 否 | 是否启用 CDN 代理（默认 false） | — |

## 4. 请求头

| Header | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `Authorization` | `string` | 是 | — | — |

## 5. 请求示例 (cURL)

```bash
curl -X POST "https://v1.apizero.cn/api/cf-dns" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "domain": "example.com",
  "host": "home",
  "ip": "<ip>",
  "token": "<token>",
  "type": "<type>",
  "ttl": "<ttl>",
  "proxied": "<proxied>"
}'
```

## 6. 响应字段

| 字段 | 类型 | 说明 | 示例 |
| --- | --- | --- | --- |
| `old_ip` | `string` | 更新前的 IP | — |
| `new_ip` | `string` | 更新后的 IP | — |
| `changed` | `bool` | 是否实际有变化 | — |
| `zone_id` | `string` | Cloudflare Zone ID | — |
| `record_id` | `string` | Cloudflare Record ID | — |

## 7. 响应示例

```json
{
    "code": 0,
    "msg": "成功",
    "data": {
        "message": "DNS 记录更新成功",
        "full_name": "home.example.com",
        "type": "A",
        "old_ip": "1.2.3.4",
        "new_ip": "5.6.7.8",
        "changed": true
    }
}
```

## 8. 错误码

| code | status | 说明 |
| --- | --- | --- |
| `4000` | `—` | 参数缺失或格式错误（IP 类型与 type 不匹配等） |
| `5020` | `—` | Cloudflare 接口失败（Token 无效 / Zone 未找到 / 记录不存在） |

## 9. 变更日志

- **1.0.0** (2026-05-07)
  - 首次上线 · IPv4/IPv6 + 代理状态控制

---

**极数本源** · 全部 API: `https://apizero.cn/aidocs` · 人类版本：`https://apizero.cn/marketplace/cf-dns`

Source: `https://apizero.cn/aidocs/cf-dns/raw.md`
Last updated: 2026-05-11T16:16:07+08:00
