# Cloudflare DNS Records (`cloudflare.dns_records`)

Lists the DNS records of one of your Cloudflare zones, filtered by type, name, content or proxy status.

Docs: https://primaryapi.com/docs/api-reference/cloudflare/dns_records

- Endpoint: `POST https://api.primaryapi.com/v1/run/cloudflare.dns_records`
- Category: Web Scraping · Platform: `cloudflare` · Kind: list · Status: live
- Price: 1 credit per call. Every call costs the same, including calls that were retried automatically.
- Billing unit: per successful call
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=cloudflare.dns_records`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `zone` | string | yes |  | max 253 chars | The zone (domain) on Cloudflare: its domain name, for example "example.com", or its 32-character zone id from cloudflare.zones. |
| `type` | enum | no |  | one of: A, AAAA, CAA, CERT, CNAME, DNSKEY, DS, HTTPS, LOC, MX, NAPTR, NS, OPENPGPKEY, PTR, SMIMEA, SRV, SSHFP, SVCB, TLSA, TXT, URI | Only records of this type, for example "A", "CNAME", "MX" or "TXT". |
| `name` | string | no |  | max 255 chars | Only records with this name: "@" for the zone apex, a single label such as "www" (inside the zone), or the full name "www.example.com". |
| `content` | string | no |  | max 4000 chars | Only records with exactly this content (case-insensitive), for example an IP address. |
| `proxied` | boolean | no |  |  | Only proxied (true) or DNS-only (false) records. |
| `order` | enum | no | "type" | one of: type, name, content, ttl, proxied | Sort field (default type). |
| `direction` | enum | no | "asc" | one of: asc, desc | Sort direction (default asc). |
| `limit` | integer | no | 100 | 1–500 | Maximum number of results to return (1-500, default 100). |
| `cursor` | string | no |  |  | Opaque pagination cursor: pass the previous response's nextCursor. |
| `connection` | string | no |  | max 200 chars | Which connected account to use when the workspace has several for this provider: the customId you gave it (exact), its connection id ("con_…"), its handle (login, email or @handle) or its name. Optional; prefer the customId or id, which never match two accounts. |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `records` | object[] |  |
| `records[].id` | string | DNS record id (use it to update or delete the record) |
| `records[].type` | string | A, AAAA, CNAME, MX, TXT, NS, CAA, SRV … |
| `records[].name` | string | Full record name, in Punycode |
| `records[].content` | string \| null | The value; for CAA and SRV a formatted summary of `data` |
| `records[].proxied` | boolean | Traffic goes through Cloudflare (orange cloud) |
| `records[].proxiable` | boolean \| null | Whether the record can be proxied |
| `records[].ttl` | integer | Seconds; 1 = automatic |
| `records[].priority` | integer \| null | MX (and URI) preference |
| `records[].data` | object \| null | The parts of CAA, SRV and other structured records |
| `records[].comment` | string \| null |  |
| `records[].tags` | string[] |  |
| `records[].createdAt` | string \| null |  |
| `records[].modifiedAt` | string \| null |  |
| `zoneId` | string | Cloudflare zone id |
| `zone` | string | The zone’s domain name |
| `nextCursor` | string \| null |  |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

Pagination: pass the previous response’s `nextCursor` as `cursor` to get the next page; `nextCursor: null` means there are no more results.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/cloudflare.dns_records" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"zone":"example.com","limit":2}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "records": [
        {
          "id": "372e67954025e0ba6aaa6d586b9e0b59",
          "type": "A",
          "name": "www.example.com",
          "content": "198.51.100.4",
          "proxied": true,
          "proxiable": true,
          "ttl": 1,
          "priority": null,
          "data": null,
          "comment": "Web server",
          "tags": [],
          "createdAt": "2014-01-01T05:20:00.123Z",
          "modifiedAt": "2014-01-01T05:20:00.123Z"
        },
        {
          "id": "9a7806061c88ada191ed06f989cc3dac",
          "type": "SRV",
          "name": "_xmpp._tcp.example.com",
          "content": "5 5223 server.example.com",
          "proxied": false,
          "proxiable": false,
          "ttl": 1,
          "priority": 10,
          "data": {
            "port": 5223,
            "priority": 10,
            "target": "server.example.com",
            "weight": 5
          },
          "comment": null,
          "tags": [],
          "createdAt": "2022-11-08T15:57:39.585Z",
          "modifiedAt": "2022-11-08T15:57:39.585Z"
        }
      ],
      "zoneId": "023e105f4ecef8ad9ca31a8372d0c353",
      "zone": "example.com",
      "nextCursor": null
    }
  },
  "provider": "PrimaryAPI",
  "credits": 1,
  "items": 2,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z",
  "nextCursor": null
}
```

## Pricing and reliability

- Usual price: 1 credit per call
- Price ceiling: the usual price, even when a call is retried. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=cloudflare.dns_records`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Notes

Runs as your connected Cloudflare account (read-only). Pass the zone by domain name or zone id. A ttl of 1 means automatic. A zone the account cannot see is a miss (found: false, reason zone_not_found), not an error. Record ids from here feed cloudflare.update_dns_record and cloudflare.delete_dns_record. Results are never stored.

