Rulesets

Rulesets

Methods

list(, ): <>
get/{accounts_or_zones}/{account_or_zone_id}/rulesets

Fetches all rulesets.

get(, , ):
get/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}

Fetches the latest version of an account or zone ruleset.

create(, ):
post/{accounts_or_zones}/{account_or_zone_id}/rulesets

Creates a ruleset.

Security

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example: Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY

Accepted Permissions (at least one required)

Mass URL Redirects Write Magic Firewall Write L4 DDoS Managed Ruleset Write Transform Rules Write Select Configuration Write Account WAF Write Account Rulesets Write Logs Write

Parameters
kind:

Body param: The kind of the ruleset.

name: string
(minLength: 1)

Body param: The human-readable name of the ruleset.

phase:

Body param: The phase of the ruleset.

account_id?: string

Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

zone_id?: string

Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

description?: string

Body param: An informative description of the ruleset.

rules?: Array< | | | 15 more...>

Body param: The list of rules in the ruleset.

Returns
RulesetCreateResponse{

A ruleset object.

id: string

The unique ID of the ruleset.

kind:

The kind of the ruleset.

last_updated: string
(format: date-time)

The timestamp of when the ruleset was last modified.

name: string
(minLength: 1)

The human-readable name of the ruleset.

phase:

The phase of the ruleset.

The list of rules in the ruleset.

version: string

The version of the ruleset.

description?: string

An informative description of the ruleset.

Request example
200Example
update(, , ):
put/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}

Updates an account or zone ruleset, creating a new version.

delete(, , ): void
delete/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}

Deletes all versions of an existing account or zone ruleset.

Domain types

Kind = "managed" | "custom" | "root" | 1 more...

The kind of the ruleset.

Phase = "ddos_l4" | "ddos_l7" | "http_config_settings" | 20 more...

The phase of the ruleset.

Ruleset{…}

A ruleset object.

Rulesets

Phases

Rulesets.Phases

Methods

get(, , ):
get/{accounts_or_zones}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint

Fetches the latest version of the account or zone entry point ruleset for a given phase.

update(, , ):
put/{accounts_or_zones}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint

Updates an account or zone entry point ruleset, creating a new version.

Rulesets.Phases.Versions

Methods

list(, , ): <>
get/{accounts_or_zones}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint/versions

Fetches the versions of an account or zone entry point ruleset.

get(, , , ):
get/{accounts_or_zones}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint/versions/{ruleset_version}

Fetches a specific version of an account or zone entry point ruleset.

Rulesets.Rules

Methods

create(, , ):
post/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}/rules

Adds a new rule to an account or zone ruleset. The rule will be added to the end of the existing list of rules in the ruleset by default.

edit(, , , ):
patch/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}

Updates an existing rule in an account or zone ruleset.

delete(, , , ):
delete/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}

Deletes an existing rule from an account or zone ruleset.

Domain types

BlockRule{…}
CompressResponseRule{…}
DDoSDynamicRule{…}
ExecuteRule{…}
ForceConnectionCloseRule{…}
LogCustomFieldRule{…}
LogRule{…}
Logging{…}

An object configuring the rule's logging behavior.

ManagedChallengeRule{…}
RedirectRule{…}
RewriteRule{…}
RouteRule{…}
RulesetRule{…}
ScoreRule{…}
ServeErrorRule{…}
SetCacheSettingsRule{…}
SetConfigRule{…}
SkipRule{…}
Rulesets

Versions

Rulesets.Versions

Methods

list(, , ): <>
get/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}/versions

Fetches the versions of an account or zone ruleset.

get(, , , ):
get/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}/versions/{ruleset_version}

Fetches a specific version of an account or zone ruleset.

delete(, , , ): void
delete/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}/versions/{ruleset_version}

Deletes an existing version of an account or zone ruleset.