Common API calls
The API token used in API requests to manage WAF content scanning and custom scan expressions must have one of the following permissions:
- Zone WAF Edit
- Account WAF Edit
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:
curl --request POST \"https://api.cloudflare.com/client/v4/zones/{zone_id}/content-upload-scan/enable" \--header "Authorization: Bearer <API_TOKEN>"
To disable content scanning, use a POST
request similar to the following:
curl --request POST \"https://api.cloudflare.com/client/v4/zones/{zone_id}/content-upload-scan/disable" \--header "Authorization: Bearer <API_TOKEN>"
To obtain the current status of the content scanning feature, use a GET
request similar to the following:
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/content-upload-scan/settings" \--header "Authorization: Bearer <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:
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/content-upload-scan/payloads" \--header "Authorization: Bearer <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:
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/content-upload-scan/payloads" \--header "Authorization: Bearer <API_TOKEN>" \--header "Content-Type: application/json" \--data '[ { "payload": "lookup_json_string(http.request.body.raw, \"file\")" }]'
Use a DELETE
request similar to the following:
curl --request DELETE \"https://api.cloudflare.com/client/v4/zones/{zone_id}/content-upload-scan/payloads/{expression_id}" \--header "Authorization: Bearer <API_TOKEN>"