Skip to content
Software capabilities
Cloudflare

Update or overwrite a DNS record

Update an existing DNS record with PATCH or overwrite it with PUT. The TypeScript client exposes these operations as edit and update, respectively.

Documentation reviewed · 4 methods with sources

Ways to do it

  1. API: PATCH /zones/{zone_id}/dns_records/{dns_record_id}
  2. SDK: client.dns.records.edit()
  3. API: PUT /zones/{zone_id}/dns_records/{dns_record_id}
  4. SDK: client.dns.records.update()
API

PATCH /zones/{zone_id}/dns_records/{dns_record_id}

Change selected fields on an existing record.

Read source: Cloudflare API: Update DNS Record
Requirements
A zone ID, record ID, an API token with DNS Write when using token auth, and a JSON body with the changes.
Limitations
The editable fields depend on the record type. The endpoint documentation requires priority for MX and URI records.
SDK

client.dns.records.edit()

Call client.dns.records.edit to apply the PATCH operation.

Read source: Generated Cloudflare TypeScript DNS method: PATCH /zones/{zone_id}/dns_records/{dns_record_id}
Requirements
An authenticated Cloudflare TypeScript client, dnsRecordID, and RecordEditParams with zone_id, name, ttl, type, and any record-specific fields.
Limitations
Version 7.4.0 types priority as optional. The endpoint documentation requires it for MX and URI records.
API

PUT /zones/{zone_id}/dns_records/{dns_record_id}

Replace the existing record with the supplied values.

Read source: Cloudflare API: Overwrite DNS Record
Requirements
A zone ID, record ID, an API token with DNS Write when using token auth, and a JSON body describing the replacement.
Limitations
Use PATCH for a partial change. The endpoint documentation requires priority for MX and URI records.
SDK

client.dns.records.update()

Call client.dns.records.update to apply the PUT operation.

Read source: Generated Cloudflare TypeScript DNS method: PUT /zones/{zone_id}/dns_records/{dns_record_id}
Requirements
An authenticated Cloudflare TypeScript client, dnsRecordID, and RecordUpdateParams with zone_id, name, ttl, type, and any record-specific fields.
Limitations
Version 7.4.0 types priority as optional. The endpoint documentation requires it for MX and URI records.