PHP Client for Cloudflare API
Rulesets

Rules

Rules endpoint reference.

Create

Adds a new rule to 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.
valuesRule|arrayYesA rule object.
php
$response = $client->rulesets()->rules()->create('ACCOUNT_ID', 'ZONE_ID', 'RULESET_ID', $values);
View this operation on the Cloudflare API Reference

Edit

Updates an existing rule in a ruleset, creating a new version of the ruleset.

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

Delete

Deletes an existing rule from a ruleset, creating a new version of the ruleset.

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