Common API calls (4)
Last updated Apr 16, 2026 The following examples address common scenarios of using the Cloudflare API to manage and configure leaked credentials detection.
If you are using Terraform, refer to Terraform configuration examples.
General operations
The following API examples cover basic operations such as enabling and disabling the leaked credentials detection.
Turn on leaked credentials detection
To turn on leaked credentials detection, use a POST request similar to the following:
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Zone WAF Write</code>
- <code>Account WAF Write</code>
</details>
Update the Leaked Credential Checks status for a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"enabled": true
}'
Turn off leaked credentials detection
To turn off leaked credentials detection, use a POST request similar to the following:
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Zone WAF Write</code>
- <code>Account WAF Write</code>
</details>
Update the Leaked Credential Checks status for a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"enabled": false
}'
Get status of leaked credentials detection
To obtain the current status of the leaked credentials detection, use a GET request similar to the following:
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Zone WAF Write</code>
- <code>Zone WAF Read</code>
- <code>Account WAF Write</code>
- <code>Account WAF Read</code>
</details>
Get the Leaked Credential Checks status for a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks" \
--request GET \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{
"result": {
"enabled": true
},
"success": true,
"errors": [],
"messages": []
}
Custom detection location operations
The following API examples cover operations on custom detection locations for leaked credentials detection.
Add a custom detection location
To add a custom detection location, use a POST request similar to the following:
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Zone WAF Write</code>
- <code>Account WAF Write</code>
</details>
Create a custom detection location for a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks/detections" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"username": "lookup_json_string(http.request.body.raw, \"user\")",
"password": "lookup_json_string(http.request.body.raw, \"secret\")"
}'
Get existing custom detection locations
To get a list of existing custom detection locations, use a GET request similar to the following:
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Zone WAF Write</code>
- <code>Zone WAF Read</code>
- <code>Account WAF Write</code>
- <code>Account WAF Read</code>
</details>
List the custom detection locations of a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks/detections" \
--request GET \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{
"result": [
{
"id": "<DETECTION_ID>",
"username": "lookup_json_string(http.request.body.raw, \"user\")",
"password": "lookup_json_string(http.request.body.raw, \"secret\")"
}
// (...)
],
"success": true,
"errors": [],
"messages": []
}
Delete a custom detection location
To delete a custom detection location, use a DELETE request similar to the following:
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Zone WAF Write</code>
- <code>Account WAF Write</code>
</details>
Delete a custom detection location from a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks/detections/$DETECTION_ID" \
--request DELETE \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/waf/detections/leaked-credentials/api-calls/#page","headline":"Common API calls","description":"Manage leaked credentials detection rules and custom detections using the API.","url":"https://developers.cloudflare.com/waf/detections/leaked-credentials/api-calls/","inLanguage":"en","image":"https://developers.cloudflare.com/waf/detections/leaked-credentials/api-calls/og.png?v=373bc972a7710738","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Examples of rules for mitigating requests containing leaked credentials. title: Example mitigation rules image: https://developers.cloudflare.com/waf/detections/leaked-credentials/examples/og.png?v=23ffe249e1a10e47
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/waf/llms.txt
Use this file to discover all available pages before exploring further.
Docs