PHP Client for Cloudflare API
Client Reference

Zaraz

Zaraz: third-party tool loading, configured per zone and served from the edge.

Zaraz: third-party tool loading, configured per zone and served from the edge.

Get Config

Get the latest Zaraz configuration for a zone.

Returns whichever of the preview or published configuration was updated last. Values of secret variables are omitted — use export() to get them.

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

Update Config

Update the Zaraz configuration for a zone.

This writes the preview configuration; call publish() to make it live. Cloudflare replaces the whole configuration, so send a complete one — read the current config, change what you need, and send it back.

$config = $client->zaraz()->getConfig('ZONE_ID')->json('result');
$config['debugKey'] = 'new-debug-key';

$client->zaraz()->updateConfig('ZONE_ID', $config);
ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
valuesarrayYesThe complete configuration: `dataLayer`, `debugKey`, `settings`, `triggers`, `variables`, `tools` and `zarazVersion` are all required, with `analytics`, `consent` and `historyChange` optional.
php
$response = $client->zaraz()->updateConfig('ZONE_ID', []);
View this operation on the Cloudflare API Reference

Get Default

Get the default Zaraz configuration for a zone.

The configuration a zone starts from, useful as a baseline to reset to.

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

Export

Export the published Zaraz configuration for a zone.

Unlike getConfig(), this returns the published configuration in full, secret variable values included.

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

History

List published Zaraz configuration records for a zone.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
paramsarrayNo[]Query Parameters: `offset` (default `0`), `limit` (default `10`), `sortField` (one of `id`, `user_id`, `description`, `created_at`, `updated_at`) and `sortOrder` (`DESC` or `ASC`).
php
$response = $client->zaraz()->history('ZONE_ID', []);
View this operation on the Cloudflare API Reference

Restore

Restore a published Zaraz configuration by ID.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
configIdintYesID of the historical configuration to restore, as listed by `history()`.
php
$response = $client->zaraz()->restore('ZONE_ID', 1);
View this operation on the Cloudflare API Reference

Configs

Get published Zaraz configurations by ID.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
idsarrayYesIDs of the historical configurations to fetch.
php
$response = $client->zaraz()->configs('ZONE_ID', []);
View this operation on the Cloudflare API Reference

Get Workflow

Get the Zaraz workflow for a zone.

The workflow decides which configuration visitors are served: realtime serves the published one, preview serves the one you are editing.

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

Update Workflow

Update the Zaraz workflow for a zone.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
workflowstringYesEither `realtime` or `preview`.
php
$response = $client->zaraz()->updateWorkflow('ZONE_ID', 'WORKFLOW');
View this operation on the Cloudflare API Reference

Publish

Publish the current Zaraz preview configuration for a zone.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
descriptionstringNo''Description recorded against the published configuration, and shown in `history()`.
php
$response = $client->zaraz()->publish('ZONE_ID', 'DESCRIPTION');
View this operation on the Cloudflare API Reference
Copyright © 2026