Skip to content
Firewall
Visit Firewall on GitHub
Set theme to dark (⇧+D)

POST example

Create Ruleset

POST accounts/{account_id}/rulesets

Creates a new ruleset.

The following parameters are required.

NameDescriptionValueNotes
nameA human-readable name for the ruleset.StringThe name is immutable. You cannot change it over the lifetime of the ruleset.
descriptionOptional description for the ruleset.StringYou can change the description over the lifetime of the ruleset.
kindThe kind of ruleset the JSON object representsString

Allowed values:

  • root
  • custom

You can only create one root ruleset for your account.

Use the rules parameter to supply a list of rules that define the ruleset. For an object definition, see Rulesets API: JSON Objects.

Request

curl -X POST \"https://api.cloudflare.com/client/v4/accounts/{account_id}/rulesets" --data '{  "name": "Example ruleset",  "kind": "root",  "description": "Example ruleset description",  "rules": [    {    "action": "log",    "expression": "cf.zone.name eq \"example.com\""    }]}'

Response

{  "result": {    "id": "{ruleset_id}",    "name": "Example ruleset",    "description": "Example ruleset description",    "kind": "root",    "version": "1",    "rules": [      {        "id": "{rule_id}",        "version": "1",        "action": "log",        "expression": "cf.zone.name eq \"example.com\"",        "last_updated": "2020-07-17T15:42:37.917815Z"      }    ],    "last_updated": "2020-07-17T15:42:37.917815Z",  },  "success": true,  "errors": [],  "messages": []}