## 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.gocdn888.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"
```

### POST `/api/v2/dns-providers/{id}/refresh`

Refresh lines of all domains of an account · Authentication: Admin only

```sh
curl -X POST "https://panel.example.com/api/v2/dns-providers/{id}/refresh" \
  -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. |
| `auth_unreadable` | boolean |  | True when a credential is stored but cannot be decrypted (the master credential key does not match or the data was altered); auth_key_hint is then empty. False when no credential was ever configured (auth_key_hint is also empty). The panel uses it to tell "credential unreadable" from "no credential configured". |
| `created_at` | string |  | Created at (read-only) |
| `degrade_count` | integer |  | Number of line fallback rows (line_degrades) for root domains under this account; 0 if none. The fallback strip in the DNS settings sidebar reads it. |
| `domain_count` | integer |  | Number of root domains hosted under this account (including disabled and migrating ones); 0 if none. |
| `domains` | integer |  | Number of domains pulled. |
| `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. |
| `failed` | integer |  | Number of domains whose pull failed. |
| `gateway` | string |  | Self-hosted API gateway address (used by dnsdun only). |
| `id` | integer |  | Record ID (read-only) |
| `line_cap` | DnsLineCap |  | Line capability of an account (tag and tooltip in the DNS settings page). |
| `lines` | integer |  | Total line count of the successful pulls. |
| `name` | string |  | Name |
| `ok` | integer |  | Number of domains pulled successfully. |
| `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) |
