PHP Client for Cloudflare API
Client Reference

Rulesets

The Cloudflare Ruleset Engine allows you to create and deploy rules and rulesets in different Cloudflare products using the same basic syntax.

The Cloudflare Ruleset Engine allows you to create and deploy rules and rulesets in different Cloudflare products using the same basic syntax.

List

Fetches all rulesets.

ParamTypeRequiredDefaultDescription
accountIdstring|nullNoAccount Identifier. Provide exactly one of $accountId or $zoneId.
zoneIdstring|nullNoZone Identifier. Provide exactly one of $accountId or $zoneId.
paramsarrayNo[]Query Parameters: `cursor` and `per_page`.
php
$response = $client->rulesets()->list('ACCOUNT_ID', 'ZONE_ID', []);
View this operation on the Cloudflare API Reference

Create

Creates a ruleset.

ParamTypeRequiredDefaultDescription
accountIdstring|nullYesAccount Identifier. Provide exactly one of $accountId or $zoneId.
zoneIdstring|nullYesZone Identifier. Provide exactly one of $accountId or $zoneId.
valuesRuleset|arrayYesA ruleset object.
php
$response = $client->rulesets()->create('ACCOUNT_ID', 'ZONE_ID', $values);
View this operation on the Cloudflare API Reference

Get

Fetches the latest version of a ruleset.

ParamTypeRequiredDefaultDescription
accountIdstring|nullYesAccount Identifier. Provide exactly one of $accountId or $zoneId.
zoneIdstring|nullYesZone Identifier. Provide exactly one of $accountId or $zoneId.
rulesetIdstringYesRuleset Identifier.
php
$response = $client->rulesets()->get('ACCOUNT_ID', 'ZONE_ID', 'RULESET_ID');
View this operation on the Cloudflare API Reference

Update

Updates a ruleset, creating a new version of it.

The rules given replace the ones the ruleset holds, so send the full set, not just the ones that changed.

ParamTypeRequiredDefaultDescription
accountIdstring|nullYesAccount Identifier. Provide exactly one of $accountId or $zoneId.
zoneIdstring|nullYesZone Identifier. Provide exactly one of $accountId or $zoneId.
rulesetIdstringYesRuleset Identifier.
valuesRuleset|arrayYesA ruleset object.
php
$response = $client->rulesets()->update('ACCOUNT_ID', 'ZONE_ID', 'RULESET_ID', $values);
View this operation on the Cloudflare API Reference

Delete

Deletes all versions of an existing ruleset.

ParamTypeRequiredDefaultDescription
accountIdstring|nullYesAccount Identifier. Provide exactly one of $accountId or $zoneId.
zoneIdstring|nullYesZone Identifier. Provide exactly one of $accountId or $zoneId.
rulesetIdstringYesRuleset Identifier.
php
$response = $client->rulesets()->delete('ACCOUNT_ID', 'ZONE_ID', 'RULESET_ID');
View this operation on the Cloudflare API Reference
Copyright © 2026