Everything an AI agent can do with the Cloudflare API.

A reference guide for building AI agents: every method, how to authenticate, and the permissions each one needs.

Endpoints31
API versionv4
Last updated23 June 2026
Orientation

How the Cloudflare API works.

The Cloudflare API is how an app or AI agent works with a Cloudflare account: editing DNS records, purging cached content, deploying Workers scripts, and tuning firewall and WAF rules. Access is granted through an API token that carries named permission groups, each set to read or edit and scoped to chosen accounts or zones, so a token reaches only what it was given. There is a single continuously updated API, and Cloudflare signals retired methods through a dated deprecations list rather than new version numbers.

31Endpoints
10Capability groups
16Read
15Write
18Permissions
Authentication
Cloudflare authenticates a call with an API token sent as 'Authorization: Bearer '. A token carries a chosen set of permission groups, each read or edit, scoped to specific accounts or zones, so it grants only what it was given. A legacy Global API Key, sent through the X-Auth-Email and X-Auth-Key headers, still works but carries the full access of the user and cannot be scoped down; Cloudflare recommends tokens instead.
Permissions
Access is governed by permission groups with short names, like Zone Read, DNS Write, Workers Scripts Write, Workers R2 Storage Write, Page Rules Write, Zone WAF Write, Cache Purge, SSL and Certificates Write, and Load Balancers Write. Each group is set to read or edit and attached to a token at one scope, either an account or a zone. A call that needs a group the token lacks returns 403. The full set of groups can be listed through the IAM permission-groups endpoint.
Versioning
The API is unversioned beyond the v4 path. There is a single, continuously updated API at https://api.cloudflare.com/client/v4, and Cloudflare signals change through a dated deprecations list rather than new version numbers. A deprecated method keeps working until its stated end-of-life date, like the in-place DNS record type change that ends on 30 June 2026, and the deprecated Firewall Rules and Filters APIs replaced by the Rulesets API.
Data model
The API is resource-oriented JSON over HTTPS at https://api.cloudflare.com/client/v4. Every response is wrapped in an envelope with a success boolean, an errors array, a messages array, and the data in a result field. Account-scoped resources, like Workers and R2 buckets, sit under /accounts/{account_id}, while zone-scoped resources, like DNS records, firewall rulesets, and Page Rules, sit under /zones/{zone_id}. A separate GraphQL endpoint serves analytics.
Connect & authenticate

Connection & authentication methods.

How an app or AI agent connects to Cloudflare determines what it can reach. There is a route for making calls, a route for receiving notifications, and a hosted server that exposes Cloudflare to agents, and each is governed by the token behind it and the permissions that token carries.

Ways to connect

REST API

The REST API answers at https://api.cloudflare.com/client/v4. Calls authenticate with an API token sent as a Bearer token, return a JSON envelope with a success boolean and errors and messages arrays, and the data in a result field. Account-scoped resources sit under /accounts/{account_id} and zone-scoped resources under /zones/{zone_id}.

Best forConnecting an app or AI agent to Cloudflare.
Governed byThe API token and the permission groups it carries.
Docs ↗

MCP server (Model Context Protocol)

Cloudflare runs a hosted Model Context Protocol server at https://mcp.cloudflare.com/mcp that exposes the whole API, over 2,500 endpoints, through a search and an execute tool. It authenticates with OAuth, with API tokens as a fallback for automation. Cloudflare also runs product-specific servers, like documentation at https://docs.mcp.cloudflare.com/mcp, Workers bindings at https://bindings.mcp.cloudflare.com/mcp, observability at https://observability.mcp.cloudflare.com/mcp, and analytics over GraphQL at https://graphql.mcp.cloudflare.com/mcp.

Best forConnecting an AI agent to Cloudflare through MCP.
Governed byThe OAuth grant or the API token and the permission groups it carries.
Docs ↗

GraphQL analytics API

A separate GraphQL endpoint at https://api.cloudflare.com/client/v4/graphql serves analytics and metrics with a typed schema. It carries its own quota, capped at 320 queries per five minutes, with cost varying by query.

Best forQuerying Cloudflare analytics and metrics.
Governed byThe API token and the permission groups it carries.
Docs ↗

Notifications

Cloudflare delivers alerts, like security events or certificate expiry, to configured destinations such as a webhook or email. The destination is set up per account, and Cloudflare sends the alert when the chosen condition fires.

Best forReceiving Cloudflare alerts at an app or AI agent.
Governed byThe configured notification destination.
Docs ↗
Authentication

API token

An API token carries a chosen set of permission groups, each set to read or edit, scoped to specific accounts or zones. It is the recommended way to connect, because a token grants only what it was given and can be rolled or revoked on its own. The token is sent as a Bearer token in the Authorization header.

TokenBearer API token
Best forLeast-privilege access scoped to specific accounts or zones.
Docs ↗

API key (legacy)

A Global API Key authenticates with the account email and a single key that carries the full access of the user, across every account and zone they can reach. Cloudflare recommends API tokens instead, because a key cannot be scoped down. It is sent through the X-Auth-Email and X-Auth-Key headers.

TokenGlobal API Key (email + key)
Best forLegacy integrations that predate API tokens.
Docs ↗
Capability map

What an AI agent can do in Cloudflare.

The Cloudflare API is split into areas an agent can act on, like zones, DNS records, firewall rules, Workers, and R2 storage. Each area has its own methods and its own permission group, and some reach far more than others.

Zones

4 endpoints

List, read, create, and delete the zones (domains) on an account.

A write here changes real zone data, including removing a domain from Cloudflare.
View endpoints

DNS records

6 endpoints

List, read, create, overwrite, patch, and delete the DNS records in a zone.

A write here changes live DNS, which can redirect or take down a site.
View endpoints

Firewall & WAF

3 endpoints

List and read the rulesets that hold WAF and custom firewall rules, and update a ruleset's rules.

A write here changes which traffic is blocked or allowed.
View endpoints

Page Rules

3 endpoints

List, read, create, and delete the URL-pattern Page Rules in a zone.

A write here changes how matching requests are handled.
View endpoints

Cache

1 endpoint

Purge cached content from Cloudflare's edge for a zone.

A purge clears served content and forces fresh fetches from the origin.
View endpoints

Workers

4 endpoints

List Workers scripts, read a script, upload or update a script, and delete one.

A write here deploys or removes code that runs on every matching request.
View endpoints

R2 storage

3 endpoints

List the R2 object-storage buckets on an account, read one, and create a bucket.

A write here creates or changes object-storage buckets.
View endpoints

SSL/TLS

3 endpoints

List custom SSL certificates in a zone and read or change Universal SSL settings.

A write here can change how the zone serves HTTPS.
View endpoints

Load Balancers

2 endpoints

List the load balancers in a zone and create a new one.

A write here changes how traffic is steered across pools.
View endpoints

Accounts

2 endpoints

List the accounts a token can reach and read a single account's details.

A write here changes account-level settings.
View endpoints
Endpoint reference

Every Cloudflare API method.

Filter by method, access, or permission, or search any path. Select a row for version detail, rate limits, the related webhook event, and the source.

MethodEndpointWhat it doesAccessPermissionVersion

Zones

List, read, create, and delete the zones (domains) on an account.4

Read-only. Zone scope. Results are filtered to the zones the token can reach.

Acts onzone
Permission (capability)Zone Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Read-only. Zone scope.

Acts onzone
Permission (capability)Zone Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs the account to be named in the request body. Zone scope.

Acts onzone
Permission (capability)Zone Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Irreversible; the domain stops being proxied by Cloudflare. Zone scope.

Acts onzone
Permission (capability)Zone Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

DNS records

List, read, create, overwrite, patch, and delete the DNS records in a zone.6

Read-only. Zone scope.

Acts ondns_record
Permission (capability)DNS Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Read-only. Zone scope.

Acts ondns_record
Permission (capability)DNS Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Zone scope. Edits live DNS, which resolves publicly within seconds.

Acts ondns_record
Permission (capability)DNS Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Replaces the whole record. Changing the type of an existing record via the API is deprecated since 23 January 2026 and ends on 30 June 2026. Zone scope.

Acts ondns_record
Permission (capability)DNS Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Patches only the fields sent, leaving the rest intact. Zone scope.

Acts ondns_record
Permission (capability)DNS Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Removes the record from live DNS. Zone scope.

Acts ondns_record
Permission (capability)DNS Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Firewall & WAF

List and read the rulesets that hold WAF and custom firewall rules, and update a ruleset's rules.3

Read-only; the list omits each ruleset's rules. The standalone Firewall Rules and Filters APIs are deprecated since 15 June 2025 in favor of these rulesets. Zone scope.

Acts onruleset
Permission (capability)Zone WAF Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Read-only. Zone scope.

Acts onruleset
Permission (capability)Zone WAF Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Replaces the ruleset's full set of rules, changing what traffic is blocked or allowed. Zone scope.

Acts onruleset
Permission (capability)Zone WAF Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Page Rules

List, read, create, and delete the URL-pattern Page Rules in a zone.3

Read-only. Zone scope.

Acts onpagerule
Permission (capability)Page Rules Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Zone scope. A zone has a fixed quota of active Page Rules by plan.

Acts onpagerule
Permission (capability)Page Rules Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Zone scope.

Acts onpagerule
Permission (capability)Page Rules Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Cache

Purge cached content from Cloudflare's edge for a zone.1

Zone scope. A purge-everything is limited to roughly one request every few seconds per zone.

Acts oncache
Permission (capability)Cache Purge
VersionAvailable since the API’s base version
Webhook eventNone
Rate limit~5 purge-everything calls per second per zone

Workers

List Workers scripts, read a script, upload or update a script, and delete one.4

Read-only. Account scope.

Acts onworker_script
Permission (capability)Workers Scripts Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Read-only. Account scope.

Acts onworker_script
Permission (capability)Workers Scripts Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Sends the script as multipart form data and puts the code live without touching its config or metadata. Account scope.

Acts onworker_script
Permission (capability)Workers Scripts Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Removes the deployed code. Account scope.

Acts onworker_script
Permission (capability)Workers Scripts Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

R2 storage

List the R2 object-storage buckets on an account, read one, and create a bucket.3

Read-only. Account scope.

Acts onr2_bucket
Permission (capability)Workers R2 Storage Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Read-only. Account scope.

Acts onr2_bucket
Permission (capability)Workers R2 Storage Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Account scope. Creates storage that can hold objects and incur cost.

Acts onr2_bucket
Permission (capability)Workers R2 Storage Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

SSL/TLS

List custom SSL certificates in a zone and read or change Universal SSL settings.3

Read-only. Zone scope.

Acts oncustom_certificate
Permission (capability)SSL and Certificates Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Read-only. Zone scope.

Acts onuniversal_ssl_setting
Permission (capability)SSL and Certificates Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Disabling removes active Universal SSL certificates, which can make the domain unreachable over HTTPS. Zone scope.

Acts onuniversal_ssl_setting
Permission (capability)SSL and Certificates Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Load Balancers

List the load balancers in a zone and create a new one.2

Read-only. Zone scope.

Acts onload_balancer
Permission (capability)Load Balancers Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Zone scope. Changes how requests are routed across origin pools.

Acts onload_balancer
Permission (capability)Load Balancers Write
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Accounts

List the accounts a token can reach and read a single account's details.2

Read-only. Account scope.

Acts onaccount
Permission (capability)Account Settings Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Read-only. Account scope.

Acts onaccount
Permission (capability)Account Settings Read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply
No endpoints match those filters.
Webhooks

Webhook events.

Cloudflare can notify an app or AI agent when something happens in an account, like a security event firing or a certificate nearing expiry, by sending the alert to a configured destination instead of the app repeatedly asking.

EventWhat it signalsTriggered by
No events match that search.
Rate limits & pagination

Rate limits, pagination & request size.

Cloudflare limits how fast an app or AI agent can call, through a request quota counted per user over a rolling window, with stricter quotas on a few areas like the analytics query interface.

Request rate

Cloudflare meters the API by a global limit of 1,200 requests every five minutes per user, counted cumulatively across the dashboard, an API key, and an API token. Going over blocks every call for the rest of the five-minute window and returns HTTP 429. A separate per-IP ceiling of 200 requests per second applies, and the GraphQL analytics interface has its own quota that varies by query cost and caps at 320 queries per five minutes. A few areas carry tighter limits, like purge-everything on the cache. Responses carry Ratelimit and Ratelimit-Policy headers reporting remaining quota and the window, and a retry-after header when the limit has been hit. Enterprise customers can ask support to raise these.

Pagination

List endpoints page with the page and per_page query parameters, and the response carries a result_info object with the current page, per-page count, total count, and total pages. Some newer resources, like rulesets, page with a cursor and per_page instead. The data itself is returned in the result array of the JSON envelope.

Request size

Responses are JSON wrapped in a success, errors, messages, and result envelope. An account is allowed 50 API tokens per user and 500 per account. Worker script size and other per-product ceilings are set by each product rather than the API as a whole.

Errors

Status codes & error handling.

The status codes an agent should handle, and what to do about each.

StatusCodeMeaningWhat to do
400Bad RequestThe request was malformed or a parameter was invalid. The body's errors array names the problem with an integer code and a message, and success is false.Read the errors array, correct the named parameter, and resend.
401UnauthorizedAuthentication failed, because the API token is missing, invalid, or expired, or the legacy email and key pair is wrong.Send a valid token as a Bearer credential, and roll it if it may be compromised.
403ForbiddenThe token is valid but lacks the permission group needed for this call, or is not scoped to the target account or zone.Grant the missing permission group on the token, or scope it to the right account or zone.
404Not FoundThe resource does not exist, or the token cannot see it. The path or an identifier may be wrong.Confirm the path and the account, zone, or record identifier, and that the token can reach it.
405Method Not AllowedThe HTTP method is not supported for this path, like sending POST where only GET is defined.Use the method the endpoint documents for the operation.
429Too Many RequestsThe rate limit was exceeded. The global limit is 1,200 requests per five minutes per user, after which calls are blocked for the rest of the window.Honor the retry-after header, slow the request rate, and wait for the window to reset.
500Internal Server ErrorAn error on Cloudflare's side, which can also appear as 502, 503, or 504.Retry with backoff, and contact Cloudflare support if it persists.
Versioning & freshness

Version history.

Cloudflare keeps a single, continuously updated version of its API at the v4 path, and signals retired methods through a dated deprecations list rather than minting new version numbers.

Version history

What changed, and when

Latest versionv4
v4Current version
Client API v4 (current, continuously updated)

Cloudflare serves a single, continuously updated API at https://api.cloudflare.com/client/v4. It is not versioned beyond the v4 path; new resources and fields are added in place, and retired methods are announced through a dated deprecations list with an end-of-life date rather than a new version number. An integration tracks the deprecations list and moves off a method before its end of life.

What changed
  • In-place DNS record type change via the API deprecated on 23 January 2026, ending 30 June 2026
  • Firewall Rules API and Filters API deprecated on 15 June 2025 in favor of WAF custom rules via the Rulesets API
  • WAF Managed Rules (previous version) APIs deprecated on 15 June 2025 in favor of the Rulesets API
  • Brotli setting and its API endpoints deprecated on 15 August 2024
  • Auto Minify API endpoints deprecated on 5 August 2024
  • Server-side Excludes feature and its API endpoints deprecated on 14 June 2024
2026-01-23Requires migration
In-place DNS record type change deprecated

Changing the type of an existing DNS record through the API was deprecated on 23 January 2026, with an end-of-life date of 30 June 2026. After that date, an integration recreates the record at the new type rather than changing the type of the existing one.

What changed
  • Deprecated changing an existing DNS record's type via the API
  • End of life set to 30 June 2026
2025-06-15Requires migration
Firewall Rules and legacy WAF APIs deprecated

The standalone Firewall Rules API and the Filters API were deprecated on 15 June 2025, replaced by WAF custom rules managed through the Rulesets API. The previous version of WAF Managed Rules, managed through packages, rule groups, and overrides, was deprecated on the same date in favor of the new WAF Managed Rules, also through the Rulesets API.

What changed
  • Deprecated the Firewall Rules API and the Filters API
  • Deprecated the previous-version WAF Managed Rules APIs
  • Steered both toward the Rulesets API
2024-08-15Feature update
Brotli and Auto Minify APIs deprecated

The Brotli setting and its API endpoints were deprecated on 15 August 2024, and the Auto Minify API endpoints were deprecated on 5 August 2024, after both features were retired. Earlier, on 14 June 2024, the Server-side Excludes feature and its API endpoints were deprecated.

What changed
  • Deprecated the Brotli setting and its API endpoints
  • Deprecated the Auto Minify API endpoints
  • Deprecated the Server-side Excludes feature and its API endpoints

An integration tracks the deprecations list and moves off a retired method before its end-of-life date.

Cloudflare API deprecations ↗
Questions

Cloudflare API, answered.

API token or Global API Key, which should I use?+
An API token is the better default. A token carries only the permission groups it was given, scoped to specific accounts or zones, so a leaked token reaches only what it was scoped to, and it can be rolled or revoked on its own. The legacy Global API Key carries the full access of the user across every account and zone and cannot be narrowed, so Cloudflare recommends tokens for new integrations.
What are the rate limits?+
The global limit is 1,200 requests every five minutes per user, counted cumulatively across the dashboard, an API key, and an API token. Going over blocks every call for the rest of that five-minute window and returns HTTP 429. A per-IP ceiling of 200 requests per second applies on top, and the GraphQL analytics interface has its own quota capped at 320 queries per five minutes. Enterprise customers can ask support to raise these.
How do permission groups work?+
A permission group is a named unit of access, like DNS Write or Workers Scripts Read, set to read or edit and attached to a token at a scope, either an account or a zone. A token can hold several groups, and a call that needs a group the token lacks returns 403. The complete list of groups, with each one's id and scope, comes from the IAM permission-groups endpoint.
How is the API versioned?+
The API is not versioned beyond the v4 path. There is one continuously updated API, and Cloudflare announces retired methods through a dated deprecations list rather than minting new version numbers. A deprecated method keeps working until its end-of-life date, so an integration tracks the list and moves off a method before it is removed.
How does the success boolean and the error model work?+
Every response is wrapped in an envelope with a success boolean, an errors array, a messages array, and a result field for the data. When success is false, each entry in the errors array has an integer code and a message naming what went wrong. The HTTP status still signals the broad category, like 400 for a bad request or 403 for a missing permission, while the errors array gives the specific reason.
What changed with Firewall Rules and the WAF?+
The standalone Firewall Rules API and the Filters API were deprecated on 15 June 2025, replaced by WAF custom rules managed through the Rulesets API. The previous version of WAF Managed Rules, managed through packages, groups, and overrides, was deprecated on the same date in favor of the new WAF Managed Rules, also through the Rulesets API. New work should use rulesets rather than the older firewall endpoints.
Does Cloudflare offer an MCP server for AI agents?+
Yes. Cloudflare runs a hosted Model Context Protocol server at https://mcp.cloudflare.com/mcp that exposes the whole API, over 2,500 endpoints, through a search tool and an execute tool, authenticating with OAuth and falling back to API tokens for automation. Cloudflare also runs product-specific servers, like documentation, Workers bindings, observability, Radar, and analytics over GraphQL, each at its own mcp.cloudflare.com subdomain.
Related

More developer API guides for agents

What is Bollard AI?

Control what every AI agent can do in Cloudflare.

Bollard AI sits between a team's AI agents and Cloudflare. Grant each agent exactly the access it needs, read or write, resource by resource, and every call is checked and logged.

  • Set read, write, or full access per agent, never a shared Cloudflare token.
  • Denied by default, so an agent reaches only what has been explicitly allowed.
  • Every call recorded in plain English: who, what, where, and the decision.
Cloudflare
Infra Agent
Read DNS records ResourceOffReadFull use
Purge cache ActionOffReadFull use
Deploy Workers scripts ActionOffReadFull use
Per-agent access, set in Bollard AI, not in Cloudflare