# Update a Cloudflare DNS Record (`cloudflare.update_dns_record`)

Changes part of an existing DNS record in one of your Cloudflare zones and returns it before and after.

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

- Endpoint: `POST https://api.primaryapi.com/v1/run/cloudflare.update_dns_record`
- Category: Web Scraping · Platform: `cloudflare` · Kind: lookup · 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.update_dns_record`
- 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. |
| `recordId` | string | yes |  | pattern: ^[0-9a-f]{32}$ | The DNS record id (32 characters), as returned by cloudflare.dns_records. |
| `name` | string | no |  | max 255 chars | New name. Record name: "@" for the zone apex, a single label such as "www" or "_dmarc" (placed inside the zone), or the full name ending in the zone, for example "www.example.com". Wildcards: "*.example.com". Punycode for non-ASCII names. |
| `content` | string | no |  | max 4000 chars | New value. The value. A: an IPv4 address. AAAA: an IPv6 address. CNAME: the target host name. MX: the mail server host name. NS: the name server. TXT: the text (Cloudflare adds the quotes). Not used for CAA and SRV (use `data`). |
| `priority` | integer | no |  | 0–65535 | New MX only: the preference, 0-65535 (lower is preferred). |
| `data` | object | no |  |  | CAA and SRV records only: their parts. CAA: flags, tag, value. SRV: priority, weight, port, target (the record name must start with _service._protocol, for example "_sip._tcp.example.com"). Parts you leave out keep their current value. |
| `data.flags` | integer | no |  | 0–255 | CAA: flags, 0-255 (usually 0). |
| `data.tag` | string | no |  | max 15 chars | CAA: the property, for example issue, issuewild or iodef. |
| `data.value` | string | no |  | max 1000 chars | CAA: the value, for example letsencrypt.org. |
| `data.priority` | integer | no |  | 0–65535 | SRV: priority, 0-65535. |
| `data.weight` | integer | no |  | 0–65535 | SRV: weight, 0-65535. |
| `data.port` | integer | no |  | 0–65535 | SRV: port, 0-65535. |
| `data.target` | string | no |  | max 253 chars | SRV: the target host name. |
| `ttl` | 1 \| integer | no |  |  | New Time to live in seconds: 1 = automatic (300 seconds), or 60-86400 (Enterprise zones may go down to 30). Proxied records always use 1. |
| `proxied` | boolean | no |  |  | Send the traffic through Cloudflare (orange cloud). Only A, AAAA and CNAME records can be proxied; their TTL is then automatic. |
| `comment` | string | no |  | max 500 chars | New comment. Your note on the record (not served in DNS). Up to 100 characters on the Free plan, 500 on other plans; no line breaks. |
| `tags` | string[] | no |  | max 20 items; items pattern: ^[A-Za-z0-9_-]{1,32}:[^\r\n]{0,100}$ | Replaces all tags. Tags as name:value, for example "team:web" (not served in DNS). Not available on the Free plan; up to 20 per record. |
| `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 |
|---|---|---|
| `zoneId` | string | Cloudflare zone id |
| `zone` | string | The zone’s domain name |
| `record` | object | The record after the change |
| `record.id` | string | DNS record id (use it to update or delete the record) |
| `record.type` | string | A, AAAA, CNAME, MX, TXT, NS, CAA, SRV … |
| `record.name` | string | Full record name, in Punycode |
| `record.content` | string \| null | The value; for CAA and SRV a formatted summary of `data` |
| `record.proxied` | boolean | Traffic goes through Cloudflare (orange cloud) |
| `record.proxiable` | boolean \| null | Whether the record can be proxied |
| `record.ttl` | integer | Seconds; 1 = automatic |
| `record.priority` | integer \| null | MX (and URI) preference |
| `record.data` | object \| null | The parts of CAA, SRV and other structured records |
| `record.comment` | string \| null |  |
| `record.tags` | string[] |  |
| `record.createdAt` | string \| null |  |
| `record.modifiedAt` | string \| null |  |
| `previous` | object | The record before the change (to undo it, send these values back) |
| `previous.id` | string | DNS record id (use it to update or delete the record) |
| `previous.type` | string | A, AAAA, CNAME, MX, TXT, NS, CAA, SRV … |
| `previous.name` | string | Full record name, in Punycode |
| `previous.content` | string \| null | The value; for CAA and SRV a formatted summary of `data` |
| `previous.proxied` | boolean | Traffic goes through Cloudflare (orange cloud) |
| `previous.proxiable` | boolean \| null | Whether the record can be proxied |
| `previous.ttl` | integer | Seconds; 1 = automatic |
| `previous.priority` | integer \| null | MX (and URI) preference |
| `previous.data` | object \| null | The parts of CAA, SRV and other structured records |
| `previous.comment` | string \| null |  |
| `previous.tags` | string[] |  |
| `previous.createdAt` | string \| null |  |
| `previous.modifiedAt` | string \| null |  |
| `changed` | string[] | The fields that were sent to Cloudflare |

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.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/cloudflare.update_dns_record" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"zone":"example.com","recordId":"372e67954025e0ba6aaa6d586b9e0b59","content":"203.0.113.10"}'
```

## 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": {
      "zoneId": "023e105f4ecef8ad9ca31a8372d0c353",
      "zone": "example.com",
      "record": {
        "id": "372e67954025e0ba6aaa6d586b9e0b59",
        "type": "A",
        "name": "www.example.com",
        "content": "203.0.113.10",
        "proxied": true,
        "proxiable": true,
        "ttl": 1,
        "priority": null,
        "data": null,
        "comment": "Web server",
        "tags": [],
        "createdAt": "2014-01-01T05:20:00.123Z",
        "modifiedAt": "2026-11-09T08:00:00.123Z"
      },
      "previous": {
        "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"
      },
      "changed": [
        "content"
      ]
    }
  },
  "provider": "PrimaryAPI",
  "credits": 1,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z"
}
```

## 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.update_dns_record`

## 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 and needs the "Manage DNS" permission. Only the fields you pass change; the rest of the record stays as it is. This changes the live configuration of your Cloudflare zone right away: there is no undo, no preview and no automatic retry. A call that times out may still have gone through, so read the current state (cloudflare.dns_records) before trying again. Repeating it with the same Idempotency-Key and input returns the first call’s stored result instead of changing the zone again. The response carries the record before the change, so you can put it back with another update. A record id that does not exist in the zone is a miss (found: false, reason record_not_found).

