Create a custom ruleset
Use the Create an account ruleset operation to create a custom ruleset, making sure that you:
- Set the
kindfield tocustom. - Specify the name of the phase where you want to create the custom ruleset in the
phasefield.
The following request creates a new custom ruleset. The response will include the ID of the new custom ruleset in the id field.
Required API token permissions
At least one of the following token permissions
is required:
Mass URL Redirects WriteMagic Firewall WriteL4 DDoS Managed Ruleset WriteTransform Rules WriteSelect Configuration WriteAccount WAF WriteAccount Rulesets WriteLogs Write
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/rulesets \ --request POST \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --json '{ "name": "Custom Ruleset 1", "description": "My First Custom Ruleset", "kind": "custom", "phase": "http_request_firewall_custom" }'{ "result": { "id": "f82ccda3d21f4a02825d3fe45b5e1c10", "name": "Custom Ruleset 1", "description": "My First Custom Ruleset", "kind": "custom", "version": "1", "last_updated": "2021-03-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.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark