Common API calls
The API token used in API requests to manage the leaked credentials detection and custom detection locations 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 the leaked credentials detection.
To turn on leaked credentials detection, use a POST
request similar to the following:
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/leaked-credential-checks" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>" \--header "Content-Type: application/json" \--data '{ "enabled": true }'
To turn off leaked credentials detection, use a POST
request similar to the following:
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/leaked-credential-checks" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>" \--header "Content-Type: application/json" \--data '{ "enabled": false }'
To obtain the current status of the leaked credentials detection, use a GET
request similar to the following:
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/leaked-credential-checks" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>"
{ "result": { "enabled": true }, "success": true, "errors": [], "messages": []}
The following API examples cover operations on custom detection locations for leaked credentials detection.
Use a POST
request similar to the following:
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/leaked-credential-checks/detections" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>" \--header "Content-Type: application/json" \--data '{ "username": "lookup_json_string(http.request.body.raw, \"user\")", "password": "lookup_json_string(http.request.body.raw, \"secret\")"}'
To get a list of existing custom detection locations, use a GET
request similar to the following:
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/leaked-credential-checks/detections" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>"
{ "result": [ { "id": "<ITEM_ID>", "username": "lookup_json_string(http.request.body.raw, \"user\")", "password": "lookup_json_string(http.request.body.raw, \"secret\")" } // (...) ], "success": true, "errors": [], "messages": []}
Use a DELETE
request similar to the following:
curl --request DELETE \"https://api.cloudflare.com/client/v4/zones/{zone_id}/leaked-credential-checks/detections/{item_id}" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>"