## DNS providers (`dns-providers`)

Admin only. Stores DNS provider accounts (such as Alibaba Cloud or Cloudflare); credentials are verified online before saving and only the last 4 characters are ever returned.

Authentication: Admin only · Docs: https://www-demo.kuxitong.com/en/docs/api/dns-providers

### GET `/api/v2/dns-providers`

List DNS providers · Authentication: Admin only

Query parameters:

| Field | Type | Required | Description |
|---|---|---|---|
| `page` | integer |  | Page number, starting from 1 Default: 1 |
| `page_size` | integer |  | Items per page Default: 20 |
| `sort` | string |  | Sort fields, comma-separated; prefix `-` for descending, e.g. `-created_at,id` |
| `type` | string |  | Only list providers of this type (such as aliyun). |

```sh
curl "https://panel.example.com/api/v2/dns-providers" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### POST `/api/v2/dns-providers`

Create DNS provider · Authentication: Admin only

Request body:

| Field | Type | Required | Description |
|---|---|---|---|
| `auth_id` | string |  | Credential ID (Alibaba Cloud AccessKey ID, DNSPod Token ID or Tencent Cloud SecretId, Cloudflare email; empty when a Cloudflare API Token is used). |
| `auth_key` | string |  | Credential (AccessKey Secret / Token / SecretKey / API Key); required on create, omitted or empty on update = keep the existing value. Stored encrypted. |
| `expected_updated_at` | string |  | Optimistic lock (used on update) - the updated_at of the resource as the caller read it. If it differs from the stored one, 409 stale_version is returned and nothing is saved; omit to skip the check; ignored on create. |
| `gateway` | string |  | Self-hosted API gateway address (used by dnsdun only). |
| `name` | string | Yes | Name |
| `remark` | string |  | Remark |
| `ttl` | integer |  | Default TTL (seconds) of records under this account. |
| `type` | string | Yes | Provider type: aliyun, cloudflare, dnspod_cn, dnspod_com, dns_la, dnsdotcom, dnsdun. |

```sh
curl -X POST "https://panel.example.com/api/v2/dns-providers" \
  -H "X-API-Key: $GOCDN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"auth_id":"LTAI-example","auth_key":"${DNS_AUTH_KEY}","name":"main-aliyun","ttl":120,"type":"aliyun"}'
```

### GET `/api/v2/dns-providers/{id}`

Get DNS provider · Authentication: Admin only

```sh
curl "https://panel.example.com/api/v2/dns-providers/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### PUT `/api/v2/dns-providers/{id}`

Update DNS provider · Authentication: Admin only

Request body:

| Field | Type | Required | Description |
|---|---|---|---|
| `auth_id` | string |  | Credential ID (Alibaba Cloud AccessKey ID, DNSPod Token ID or Tencent Cloud SecretId, Cloudflare email; empty when a Cloudflare API Token is used). |
| `auth_key` | string |  | Credential (AccessKey Secret / Token / SecretKey / API Key); required on create, omitted or empty on update = keep the existing value. Stored encrypted. |
| `expected_updated_at` | string |  | Optimistic lock (used on update) - the updated_at of the resource as the caller read it. If it differs from the stored one, 409 stale_version is returned and nothing is saved; omit to skip the check; ignored on create. |
| `gateway` | string |  | Self-hosted API gateway address (used by dnsdun only). |
| `name` | string | Yes | Name |
| `remark` | string |  | Remark |
| `ttl` | integer |  | Default TTL (seconds) of records under this account. |
| `type` | string | Yes | Provider type: aliyun, cloudflare, dnspod_cn, dnspod_com, dns_la, dnsdotcom, dnsdun. |

```sh
curl -X PUT "https://panel.example.com/api/v2/dns-providers/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"auth_id":"LTAI-example","auth_key":"${DNS_AUTH_KEY}","name":"main-aliyun","ttl":120,"type":"aliyun"}'
```

### DELETE `/api/v2/dns-providers/{id}`

Delete DNS provider · Authentication: Admin only

```sh
curl -X DELETE "https://panel.example.com/api/v2/dns-providers/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### GET `/api/v2/dns-providers/{id}/lines`

Fetch DNS provider lines · Authentication: Admin only

Query parameters:

| Field | Type | Required | Description |
|---|---|---|---|
| `domain` | string | Yes | Root domain, such as example.com. |

```sh
curl "https://panel.example.com/api/v2/dns-providers/{id}/lines" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

DNS providers object:

| Field | Type | Required | Description |
|---|---|---|---|
| `auth_id` | string |  | Credential ID (Alibaba Cloud AccessKey ID, DNSPod Token ID or Tencent Cloud SecretId, Cloudflare email; empty when a Cloudflare API Token is used). |
| `auth_key` | string |  | Credential (AccessKey Secret / Token / SecretKey / API Key); required on create, omitted or empty on update = keep the existing value. Stored encrypted. |
| `auth_key_hint` | string |  | Last 4 characters of the credential (padded with * in front); the original is never returned. |
| `created_at` | string |  | Created at (read-only) |
| `default_line` | string |  | ID of the default line of this provider. |
| `expected_updated_at` | string |  | Optimistic lock (used on update) - the updated_at of the resource as the caller read it. If it differs from the stored one, 409 stale_version is returned and nothing is saved; omit to skip the check; ignored on create. |
| `gateway` | string |  | Self-hosted API gateway address (used by dnsdun only). |
| `id` | integer |  | Record ID (read-only) |
| `items` | DnsLine[] |  | Items on this page |
| `lines` | DnsLine[] |  | Cached line tree from the last fetch (refreshed by GET /dns-providers/{id}/lines); an empty array if never fetched. |
| `name` | string |  | Name |
| `remark` | string |  | Remark |
| `ttl` | integer |  | Default TTL (seconds) of records under this account. |
| `type` | string |  | Provider type: aliyun, cloudflare, dnspod_cn, dnspod_com, dns_la, dnsdotcom, dnsdun. |
| `updated_at` | string |  | Updated at (read-only) |
