---
title: Rate Limits
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/terraform)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Rate Limits

#### resource cloudflare\_rate\_limit

##### required Expand Collapse

zone\_id: String

Defines an identifier.

[Link to this property](<#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20zone_id>)

period: Float64

The time in seconds (an integer value) to count matching traffic. If the count exceeds the configured threshold within this period, Cloudflare will perform the configured action.

[Link to this property](<#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20period>)

threshold: Float64

The threshold that will trigger the configured mitigation action. Configure this value along with the `period` property to establish a threshold per period.

[Link to this property](<#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20threshold>)

<details>

<summary>

action: Attributes

The action to perform when the threshold of matched traffic within the configured period is exceeded.

</summary>

mode?: String

The action to perform.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20action%20%3E%20(attribute)%20mode">Link to this property</a>

<details>

<summary>

response?: Attributes

A custom content type and reponse to return when the threshold is exceeded. The custom response configured in this object will override the custom error for the zone. This object is optional. Notes: If you omit this object, Cloudflare will use the default HTML error page. If “mode” is “challenge”, “managed\_challenge”, or “js\_challenge”, Cloudflare will use the zone challenge pages and you should not provide the “response” object.

</summary>

body?: String

The response body to return. The value must conform to the configured content type.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20action%20%3E%20(attribute)%20response%20%3E%20(attribute)%20body">Link to this property</a>

content\_type?: String

The content type of the body. Must be one of the following: <code>text/plain</code>, <code>text/xml</code>, or <code>application/json</code>.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20action%20%3E%20(attribute)%20response%20%3E%20(attribute)%20content_type">Link to this property</a>

</details>

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20action%20%3E%20(attribute)%20response">Link to this property</a>

timeout?: Float64

The time in seconds during which Cloudflare will perform the mitigation action. Must be an integer value greater than or equal to the period. Notes: If “mode” is “challenge”, “managed\_challenge”, or “js\_challenge”, Cloudflare will use the zone’s Challenge Passage time and you should not provide this value.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20action%20%3E%20(attribute)%20timeout">Link to this property</a>

</details>

[Link to this property](<#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20action>)

<details>

<summary>

match: Attributes

Determines which traffic the rate limit counts towards the threshold.

</summary>

<details>

<summary>

headers?: List\[Attributes]

</summary>

name?: String

The name of the response header to match.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20headers%20%3E%20(attribute)%20name">Link to this property</a>

op?: String

The operator used when matching: <code>eq</code> means “equal” and <code>ne</code> means “not equal”.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20headers%20%3E%20(attribute)%20op">Link to this property</a>

value?: String

The value of the response header, which must match exactly.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20headers%20%3E%20(attribute)%20value">Link to this property</a>

</details>

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20headers">Link to this property</a>

<details>

<summary>

request?: Attributes

</summary>

methods?: List\[String]

The HTTP methods to match. You can specify a subset (for example, <code>['POST','PUT']</code>) or all methods (<code>['_ALL_']</code>). This field is optional when creating a rate limit.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20request%20%3E%20(attribute)%20methods">Link to this property</a>

schemes?: List\[String]

The HTTP schemes to match. You can specify one scheme (<code>['HTTPS']</code>), both schemes (<code>['HTTP','HTTPS']</code>), or all schemes (<code>['_ALL_']</code>). This field is optional.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20request%20%3E%20(attribute)%20schemes">Link to this property</a>

url?: String

The URL pattern to match, composed of a host and a path such as <code>example.org/path*</code>. Normalization is applied before the pattern is matched. <code>*</code> wildcards are expanded to match applicable traffic. Query strings are not matched. Set the value to <code>*</code> to match all traffic to your zone.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20request%20%3E%20(attribute)%20url">Link to this property</a>

</details>

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20request">Link to this property</a>

<details>

<summary>

response?: Attributes

</summary>

origin\_traffic?: Bool

When true, only the uncached traffic served from your origin servers will count towards rate limiting. In this case, any cached traffic served by Cloudflare will not count towards rate limiting. This field is optional. Notes: This field is deprecated. Instead, use response headers and set “origin\_traffic” to “false” to avoid legacy behaviour interacting with the “response\_headers” property.

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20response%20%3E%20(attribute)%20origin_traffic">Link to this property</a>

</details>

<a href="#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match%20%3E%20(attribute)%20response">Link to this property</a>

</details>

[Link to this property](<#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20match>)

##### optional Expand Collapse

rate\_limit\_id?: String

Defines the unique identifier of the rate limit.

[Link to this property](<#(resource)%20rate_limits%20%3E%20(terraform%20resource)%20%3E%20(attribute)%20rate_limit_id>)

### cloudflare\_rate\_limit

Terraform

HTTPTypeScriptPythonGoTerraform

```
resource "cloudflare_rate_limit" "example_rate_limit" {
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
  action = {
    mode = "challenge"
    response = {
      body = "<error>This request has been rate-limited.</error>"
      content_type = "text/xml"
    }
    timeout = 86400
  }
  match = {
    headers = [{
      name = "Cf-Cache-Status"
      op = "ne"
      value = "HIT"
    }]
    request = {
      methods = ["GET", "POST"]
      schemes = ["HTTP", "HTTPS"]
      url = "*.example.org/path*"
    }
    response = {
      origin_traffic = true
    }
  }
  period = 900
  threshold = 60
}
```

#### data cloudflare\_rate\_limit

##### required Expand Collapse

rate\_limit\_id: String

Defines the unique identifier of the rate limit.

[Link to this property](<#(resource)%20rate_limits%20%3E%20(terraform%20datasource-single)%20%3E%20(attribute)%20rate_limit_id>)

zone\_id: String

Defines an identifier.

[Link to this property](<#(resource)%20rate_limits%20%3E%20(terraform%20datasource-single)%20%3E%20(attribute)%20zone_id>)

### cloudflare\_rate\_limit

Terraform

HTTPTypeScriptPythonGoTerraform

```
data "cloudflare_rate_limit" "example_rate_limit" {
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
  rate_limit_id = "372e67954025e0ba6aaa6d586b9e0b59"
}
```