PHP Client for Cloudflare API
Client Reference

DNS

DNS endpoint reference.

Scan

Scan DNS Records.

Scan for common DNS records on your domain and automatically add them to your zone. Useful if you haven't updated your nameservers yet.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
php
$response = $client->dns()->scan('ZONE_ID');
View this operation on the Cloudflare API Reference

Trigger Scan

Trigger an asynchronous scan for common DNS records on a domain.

Unlike the deprecated scan(), this does not add anything to the zone. The scan runs in the background; read what it found with scannedRecords() and decide record by record with reviewScan().

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
php
$response = $client->dns()->triggerScan('ZONE_ID');
View this operation on the Cloudflare API Reference

Scanned Records

List the DNS records discovered so far by the asynchronous scan.

These records are temporary until accepted or rejected through reviewScan(), and the scan may turn up more of them afterwards.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
php
$response = $client->dns()->scannedRecords('ZONE_ID');
View this operation on the Cloudflare API Reference

Review Scan

Accept or reject DNS records found by the scan.

Accepted records are permanently added to the zone; rejected ones are permanently deleted.

$client->dns()->reviewScan('ZONE_ID', accepts: ['record_id_a'], rejects: ['record_id_b']);
ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
acceptsarrayNo[]Scanned records to add to the zone.
rejectsarrayNo[]Scanned records to discard.
php
$response = $client->dns()->reviewScan('ZONE_ID', [], []);
View this operation on the Cloudflare API Reference

Batch

Send a batch of DNS record changes to be executed together.

Cloudflare runs the batch in a single database transaction, but propagation is not atomic: its distributed store treats each record as its own key, so changes become visible independently.

$client->dns()->batch('ZONE_ID', [
    'posts' => [['type' => 'A', 'name' => 'www', 'content' => '198.51.100.4']],
    'deletes' => [['id' => 'record_id']],
]);
ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
valuesarrayYesAny of `posts` (create), `puts` (overwrite), `patches` (partial update) and `deletes`, each a list of record operations.
paramsarrayNo[]Query Parameters: `include_shadow_metadata`.
php
$response = $client->dns()->batch('ZONE_ID', [], []);
View this operation on the Cloudflare API Reference

Usage

Get the current DNS record usage and quota for an account.

May include internal DNS usage and quota alongside the public zones'.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
php
$response = $client->dns()->usage('ACCOUNT_ID');
View this operation on the Cloudflare API Reference

List

List, search, sort, and filter a zones' DNS records.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
paramsarrayNo[]Query Parameters
php
$response = $client->dns()->list('ZONE_ID', []);
View this operation on the Cloudflare API Reference

Create

Create a new DNS record for a zone.

Notes:

  • A/AAAA records cannot exist on the same name as CNAME records.
  • NS records cannot exist on the same name as any other record type.
  • Domain names are always represented in Punycode, even if Unicode characters were used when creating the record.
ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
valuesarrayYesValues to set on DNS.
php
$response = $client->dns()->create('ZONE_ID', []);
View this operation on the Cloudflare API Reference

Export

Export BIND config.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
php
$response = $client->dns()->export('ZONE_ID');
View this operation on the Cloudflare API Reference

Import

Import BIND config.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
contentstringYesContent of BIND config to import.
proxiedboolNotrueShould DNS records be proxied.
php
$response = $client->dns()->import('ZONE_ID', 'CONTENT', true);
View this operation on the Cloudflare API Reference

Get

DNS Record Details

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
dnsRecordIdstringYesDNS ID to fetch details.
php
$response = $client->dns()->get('ZONE_ID', 'DNS_RECORD_ID');
View this operation on the Cloudflare API Reference

Edit

Apply changes to an existing DNS record, overwriting only the supplied properties.

Notes:

  • A/AAAA records cannot exist on the same name as CNAME records.
  • NS records cannot exist on the same name as any other record type.
  • Domain names are always represented in Punycode, even if Unicode characters were used when creating the record.
ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
dnsRecordIdstringYesDNS ID to update.
valuesarrayYes
php
$response = $client->dns()->edit('ZONE_ID', 'DNS_RECORD_ID', []);
View this operation on the Cloudflare API Reference

Update

Update an existing DNS record, overwriting the full configuration.

Notes:

  • A/AAAA records cannot exist on the same name as CNAME records.
  • NS records cannot exist on the same name as any other record type.
  • Domain names are always represented in Punycode, even if Unicode characters were used when creating the record.
ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
dnsRecordIdstringYesDNS ID to overwrite.
valuesarrayYes
php
$response = $client->dns()->update('ZONE_ID', 'DNS_RECORD_ID', []);
View this operation on the Cloudflare API Reference

Delete

Delete DNS Record

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
dnsRecordIdstringYesDNS ID to delete.
php
$response = $client->dns()->delete('ZONE_ID', 'DNS_RECORD_ID');
View this operation on the Cloudflare API Reference
Copyright © 2026