Skip to content
Software capabilities
Cloudflare

Create a DNS record

Create a record in a zone through the DNS Records API or the Cloudflare TypeScript client.

Documentation reviewed · 2 methods with sources

Ways to do it

  1. API: POST /zones/{zone_id}/dns_records
  2. SDK: client.dns.records.create()
API

POST /zones/{zone_id}/dns_records

Create a record in the specified zone.

Read source: Cloudflare API: Create DNS Record
Requirements
A zone ID, an API token with DNS Write when using token auth, and a JSON payload for the chosen record type.
Limitations
A and AAAA records cannot share a name with a CNAME record. NS records cannot share a name with another record type. Cloudflare represents internationalized names in Punycode. The API documentation requires priority for MX and URI records.
SDK

client.dns.records.create()

Call client.dns.records.create with the record fields.

Read source: Generated Cloudflare TypeScript DNS method: POST /zones/{zone_id}/dns_records
Requirements
An authenticated Cloudflare TypeScript client and a RecordCreateParams object 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.