跳转到主要内容

Create a custom ruleset

Use the Create an account or zone ruleset operation to create a custom ruleset, making sure that you:

  • Set the kind field to custom.
  • Specify the name of the phase where you want to create the custom ruleset in the phase field.

You can also specify the list of rules to include in the custom ruleset in the rules array. To add rules after creating the custom ruleset, refer to Add rules to a custom ruleset.

Example A - Custom ruleset at the account level

The following request creates a new custom ruleset at the account level. The response will include the ID of the new custom ruleset in the id field.

POST /accounts/{account_id}/rulesets

{
	"result": {
		"id": "f82ccda3d21f4a02825d3fe45b5e1c10",
		"name": "Custom Ruleset 1",
		"description": "My First Custom Ruleset (account)",
		"kind": "custom",
		"version": "1",
		"last_updated": "2025-08-09T10:27:30.636197Z",
		"phase": "http_request_firewall_custom"
	},
	"success": true,
	"errors": [],
	"messages": []
}

You can include a list of rules in the custom ruleset creation request. If you have not added any rules, refer to Add rules to a custom ruleset for more information.

Example B - Custom ruleset at the zone level

The following request creates a new custom ruleset at the zone level. The response will include the ID of the new custom ruleset in the id field.

POST /zones/{zone_id}/rulesets

{
	"result": {
		"id": "f82ccda3d21f4a02825d3fe45b5e1c10",
		"name": "Custom Ruleset 1",
		"description": "My First Custom Ruleset (zone)",
		"kind": "custom",
		"version": "1",
		"last_updated": "2025-08-09T10:27:30.636197Z",
		"phase": "http_request_firewall_custom"
	},
	"success": true,
	"errors": [],
	"messages": []
}

You can include a list of rules in the custom ruleset creation request. If you have not added any rules, refer to Add rules to a custom ruleset for more information.