Common API calls
The following examples address common scenarios of using the Cloudflare API to manage and configure WAF content scanning.
If you are using Terraform, refer to Terraform configuration examples.
The following API examples cover basic operations such as enabling and disabling WAF content scanning.
To enable content scanning, use a POST
request similar to the following:
Required API token permissions
At least one of the following token permissions
is required:
Zone WAF Write
Account WAF Write
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/content-upload-scan/enable" \ --request POST \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
To disable content scanning, use a POST
request similar to the following:
Required API token permissions
At least one of the following token permissions
is required:
Zone WAF Write
Account WAF Write
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/content-upload-scan/disable" \ --request POST \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
To obtain the current status of the content scanning feature, use a GET
request similar to the following:
Required API token permissions
At least one of the following token permissions
is required:
Zone WAF Write
Zone WAF Read
Account WAF Write
Account WAF Read
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/content-upload-scan/settings" \ --request GET \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
The following API examples cover operations on custom scan expressions for content scanning.
To get a list of existing custom scan expressions, use a GET
request similar to the following:
Required API token permissions
At least one of the following token permissions
is required:
Zone WAF Write
Zone WAF Read
Account WAF Write
Account WAF Read
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/content-upload-scan/payloads" \ --request GET \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{ "result": [ { "id": "<EXPRESSION_ID>", "payload": "lookup_json_string(http.request.body.raw, \"file\")" } ], "success": true, "errors": [], "messages": []}
Use a POST
request similar to the following:
Required API token permissions
At least one of the following token permissions
is required:
Zone WAF Write
Account WAF Write
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/content-upload-scan/payloads" \ --request POST \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --json '[ { "payload": "lookup_json_string(http.request.body.raw, \"file\")" } ]'
Use a DELETE
request similar to the following:
Required API token permissions
At least one of the following token permissions
is required:
Zone WAF Write
Account WAF Write
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/content-upload-scan/payloads/$EXPRESSION_ID" \ --request DELETE \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
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