Common API calls

Last updated May 5, 2026 The following sections contain example requests for common API calls. For a list of available API endpoints, refer to Endpoints.

Get all DNS protection rules

The following example retrieves the currently configured rules for Advanced DNS Protection.

Requestbash

curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_dns_protection/configs/dns_protection/rules" \
--header "Authorization: Bearer <API_TOKEN>"
---
{
  "result": [
    {
      "id": "<RULE_ID>",
      "scope": "<SCOPE>",
      "name": "<NAME>",
      "mode": "<MODE>",
      "profile_sensitivity": "<SENSITIVITY>",
      "rate_sensitivity": "<RATE>",
      "burst_sensitivity": "<BURST>",
      "created_on": "2023-10-01T13:10:38.762503+01:00",
      "modified_on": "2023-10-01T13:10:38.762503+01:00",
      }
    ],
  "success": true,
  "errors": [],
  "messages": []
}

Create DNS protection rule

The following example creates an Advanced DNS Protection rule with a global scope.

Requestbash

curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_dns_protection/configs/dns_protection/rules" \
--header "Authorization: Bearer <API_TOKEN>" \
--data '{
  "scope": "global",
  "name": "global",
  "mode": "<MODE>",
  "rate_sensitivity": "<RATE>",
  "burst_sensitivity": "<BURST>",
  "profile_sensitivity": "<SENSITIVITY>"
}'
{
  "result": {
    "id": "<RULE_ID>",
    "scope": "global",
    "name": "global",
    "mode": "<MODE>",
    "rate_sensitivity": "<RATE>",
    "burst_sensitivity": "<BURST>",
    "profile_sensitivity": "<SENSITIVITY>",
    "created_on": "2023-10-01T13:10:38.762503+01:00",
    "modified_on": "2023-10-01T13:10:38.762503+01:00",
  },
  "success": true,
  "errors": [],
  "messages": []
}

Refer to JSON objects for more information on the fields in the JSON body.

Update DNS protection rule

The following example updates an existing DNS protection rule with ID {rule_id}.

The request body can contain only the fields you want to update (from mode, profile_sensitivity, rate_sensitivity, and burst_sensitivity).

Requestbash

curl --request PATCH \
"https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_dns_protection/configs/dns_protection/rules/{rule_id}" \
--header "Authorization: Bearer <API_TOKEN>" \
--data '{
  "mode": "<NEW_MODE>",
  "profile_sensitivity": "<NEW_SENSITIVITY>",
  "rate_sensitivity": "<NEW_RATE>",
  "burst_sensitivity": "<NEW_BURST>"
}'
{
  "result": {
    "id": "<RULE_ID>",
    "scope": "<SCOPE>",
    "name": "<NAME>",
    "mode": "<NEW_MODE>",
    "profile_sensitivity": "<NEW_SENSITIVITY>",
    "rate_sensitivity": "<NEW_RATE>",
    "burst_sensitivity": "<NEW_BURST>",
    "created_on": "2023-10-01T13:10:38.762503+01:00",
    "modified_on": "2023-10-01T13:10:38.762503+01:00",
  },
  "success": true,
  "errors": [],
  "messages": []
}

Refer to JSON objects for more information on the fields in the JSON body.

Was this helpful?

YesNo

On this page

Common API calls - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ddos-protection/advanced-ddos-systems/api/dns-protection/examples/#page","headline":"Common API calls","description":"Example API requests for managing Advanced DNS Protection rules and settings.","url":"https://developers.cloudflare.com/ddos-protection/advanced-ddos-systems/api/dns-protection/examples/","inLanguage":"en","image":"https://developers.cloudflare.com/ddos-protection/advanced-ddos-systems/api/dns-protection/examples/og.png?v=ed25b9329656ba65","dateModified":"2026-05-05","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/"},"keywords":["REST API"]}


description: JSON object structure for Advanced DNS Protection API requests and responses. title: JSON objects image: https://developers.cloudflare.com/ddos-protection/advanced-ddos-systems/api/dns-protection/json-objects/og.png?v=ac75d61b21367c40


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/ddos-protection/llms.txt
Use this file to discover all available pages before exploring further.