Skip to main content
The Rate Limiting API is deprecated in favor of using the Ruleset Engine. See the deprecation notice for full details.
The Rate Limits API allows you to create and manage rate limiting rules that protect your website against denial-of-service attacks, brute-force login attempts, and other types of abusive behavior.

Create a rate limit

Creates a new rate limit for a zone.
string
required
The zone identifier
number
required
The threshold that triggers the rate limit mitigation. Configure this value along with the period property to establish a threshold per period.
number
required
The time in seconds to count matching traffic. If the count exceeds the threshold within this period, Cloudflare performs the configured action.
object
required
The action to perform when the threshold is exceeded.
string
required
The action to perform: simulate, ban, challenge, js_challenge, or managed_challenge
number
The time in seconds during which Cloudflare will perform the mitigation action. Must be greater than or equal to the period.
object
Custom response to return when threshold is exceeded.
string
Content type: text/plain, text/xml, or application/json
string
The response body to return
object
required
Determines which traffic the rate limit counts toward the threshold.
object
Request matching criteria.
string
URL pattern to match (e.g., example.org/path*). Use * for wildcards.
array
HTTP methods to match: GET, POST, PUT, DELETE, PATCH, HEAD, or _ALL_
array
HTTP schemes to match: HTTP, HTTPS, or _ALL_
object
Response matching criteria.
boolean
When true, only uncached traffic served from origin servers counts toward rate limiting.
array
Array of header matching rules.
string
The header name to match
string
Operator: eq (equal) or ne (not equal)
string
The header value to match
string
An informative summary of the rate limit rule.
boolean
When true, the rate limit is currently disabled.
array
Criteria specifying when the rate limit should be bypassed.
string
Set to url for URL-based bypass
string
The URL to bypass
string
The unique identifier of the rate limit
object
The configured action
number
The request threshold
number
The time period in seconds
object
The traffic matching criteria
boolean
Whether the rate limit is disabled

List rate limits

Fetches all rate limits for a zone.
string
required
The zone identifier
number
Page number of paginated results
number
Number of items per page

Get a rate limit

Fetches details of a single rate limit.
string
required
The rate limit identifier
string
required
The zone identifier

Update a rate limit

Updates an existing rate limit.
string
required
The rate limit identifier
string
required
The zone identifier

Delete a rate limit

Deletes an existing rate limit.
string
required
The rate limit identifier
string
required
The zone identifier

Example: Protect login endpoint

Example: API rate limiting with custom response

Migration to Ruleset Engine

For new implementations, use the Ruleset Engine instead of the deprecated Rate Limiting API. The Ruleset Engine provides more flexible and powerful rate limiting capabilities through custom rules.