Skip to content

Create a ruleset

Last updated View as MarkdownAgent setup

Creates a ruleset of a given kind in the specified phase. Allows you to create phase entry point rulesets.

Use one of the following API endpoints:

Parameters

A POST request to create a ruleset supports the following parameters in the request body:

  • name String
    • A human-readable name for the ruleset.
    • The name is immutable. You cannot change it over the lifetime of the ruleset.
  • description String Optional
    • Optional description for the ruleset.
    • You can change the description over the lifetime of the ruleset.
  • kind String
    • The kind of ruleset the JSON object represents.
    • Allowed values:
      • custom: Creates a custom ruleset
      • root: Creates a phase entry point ruleset at the account level
      • zone: Creates a phase entry point ruleset at the zone level
  • phase String
    • The name of the phase where the ruleset will be created.
    • Check the phases list or the specific Cloudflare product documentation for more information on the phases where you can create rulesets for that product.
  • rules Array<Rule> Optional
    • A list of rules to include in the ruleset.

For additional details on these parameters, refer to JSON objects.

Example - Create a custom ruleset

The following POST request creates a custom ruleset in the http_request_firewall_custom phase at the account level containing a single rule.

Required API token permissions

At least one of the following token permissions is 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
Create an account rulesetbash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/rulesets"