---
title: List account or zone rulesets
---

[Skip to content](#_top)

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

[Rulesets](https://developers.cloudflare.com/api/go/resources/rulesets)

Copy Markdown

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

---

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

# List account or zone rulesets

client.Rulesets.List(ctx, params) (\*CursorPagination\[[RulesetListResponse](<https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)>)], error)

GET/{accounts\_or\_zones}/{account\_or\_zone\_id}/rulesets

Fetches all rulesets.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Mass URL Redirects Write``Mass URL Redirects Read``Magic Firewall Write``Magic Firewall Read``L4 DDoS Managed Ruleset Write``L4 DDoS Managed Ruleset Read``Transform Rules Write``Transform Rules Read``Select Configuration Write``Select Configuration Read``Account WAF Write``Account WAF Read``Account Rulesets Read``Account Rulesets Write``Logs Write``Logs Read`

##### ParametersExpand Collapse

<details>

<summary>

params RulesetListParams

</summary>

AccountID param.Field\[string]Optional

Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

<a href="#(resource)%20rulesets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

ZoneID param.Field\[string]Optional

Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

<a href="#(resource)%20rulesets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20zone_id">Link to this property</a>

Cursor param.Field\[string]Optional

Query param: The cursor to use for the next page.

minLength1

<a href="#(resource)%20rulesets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cursor">Link to this property</a>

PerPage param.Field\[int64]Optional

Query param: The number of rulesets to return per page.

maximum50

minimum1

<a href="#(resource)%20rulesets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20per_page">Link to this property</a>

</details>

[Link to this property](<#(resource)%20rulesets%20%3E%20(method)%20list%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type RulesetListResponse struct{…}

A ruleset object.

</summary>

ID string

The unique ID of the ruleset.

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

<details>

<summary>

Kind <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20kind%20%3E%20(schema)">Kind</a>

The kind of the ruleset.

</summary>

One of the following:

const KindManaged <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20kind%20%3E%20(schema)">Kind</a> = "managed"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20kind%20%2B%20(resource)%20rulesets%20%3E%20(model)%20kind%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const KindCustom <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20kind%20%3E%20(schema)">Kind</a> = "custom"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20kind%20%2B%20(resource)%20rulesets%20%3E%20(model)%20kind%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const KindRoot <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20kind%20%3E%20(schema)">Kind</a> = "root"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20kind%20%2B%20(resource)%20rulesets%20%3E%20(model)%20kind%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

const KindZone <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20kind%20%3E%20(schema)">Kind</a> = "zone"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20kind%20%2B%20(resource)%20rulesets%20%3E%20(model)%20kind%20%3E%20(schema)%20%3E%20(member)%203">Link to this property</a>

</details>

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20kind">Link to this property</a>

LastUpdated Time

The timestamp of when the ruleset was last modified.

formatdate-time

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20last_updated">Link to this property</a>

Name string

The human-readable name of the ruleset.

minLength1

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

<details>

<summary>

Phase <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a>

The phase of the ruleset.

</summary>

One of the following:

const PhaseDDoSL4 <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "ddos\_l4"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const PhaseDDoSL7 <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "ddos\_l7"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const PhaseHTTPConfigSettings <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_config\_settings"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

const PhaseHTTPCustomErrors <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_custom\_errors"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%203">Link to this property</a>

const PhaseHTTPLogCustomFields <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_log\_custom\_fields"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%204">Link to this property</a>

const PhaseHTTPRatelimit <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_ratelimit"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%205">Link to this property</a>

const PhaseHTTPRequestCacheSettings <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_cache\_settings"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%206">Link to this property</a>

const PhaseHTTPRequestDynamicRedirect <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_dynamic\_redirect"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%207">Link to this property</a>

const PhaseHTTPRequestFirewallCustom <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_firewall\_custom"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%208">Link to this property</a>

const PhaseHTTPRequestFirewallManaged <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_firewall\_managed"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%209">Link to this property</a>

const PhaseHTTPRequestLateTransform <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_late\_transform"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2010">Link to this property</a>

const PhaseHTTPRequestOrigin <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_origin"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2011">Link to this property</a>

const PhaseHTTPRequestRedirect <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_redirect"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2012">Link to this property</a>

const PhaseHTTPRequestSanitize <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_sanitize"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2013">Link to this property</a>

const PhaseHTTPRequestSBFM <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_sbfm"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2014">Link to this property</a>

const PhaseHTTPRequestTransform <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_request\_transform"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2015">Link to this property</a>

const PhaseHTTPResponseCacheSettings <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_response\_cache\_settings"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2016">Link to this property</a>

const PhaseHTTPResponseCompression <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_response\_compression"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2017">Link to this property</a>

const PhaseHTTPResponseFirewallManaged <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_response\_firewall\_managed"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2018">Link to this property</a>

const PhaseHTTPResponseHeadersTransform <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "http\_response\_headers\_transform"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2019">Link to this property</a>

const PhaseMagicTransit <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "magic\_transit"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2020">Link to this property</a>

const PhaseMagicTransitIDsManaged <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "magic\_transit\_ids\_managed"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2021">Link to this property</a>

const PhaseMagicTransitManaged <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "magic\_transit\_managed"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2022">Link to this property</a>

const PhaseMagicTransitRatelimit <a href="https://developers.cloudflare.com/api/go/resources/rulesets#(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)">Phase</a> = "magic\_transit\_ratelimit"

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase%20%2B%20(resource)%20rulesets%20%3E%20(model)%20phase%20%3E%20(schema)%20%3E%20(member)%2023">Link to this property</a>

</details>

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20phase">Link to this property</a>

Version string

The version of the ruleset.

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20version">Link to this property</a>

Description stringOptional

An informative description of the ruleset.

<a href="#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

</details>

[Link to this property](<#(resource)%20rulesets%20%3E%20(model)%20RulesetListResponse%20%3E%20(schema)>)

### List account or zone rulesets

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/rulesets"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  page, err := client.Rulesets.List(context.TODO(), rulesets.RulesetListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
```

200 example

```
{
  "errors": [
    {
      "message": "something bad happened",
      "code": 10000,
      "source": {
        "pointer": "/rules/0/action"
      }
    }
  ],
  "messages": [
    {
      "message": "something bad happened",
      "code": 10000,
      "source": {
        "pointer": "/rules/0/action"
      }
    }
  ],
  "result": [
    {
      "id": "2f2feab2026849078ba485f918791bdc",
      "kind": "root",
      "last_updated": "2000-01-01T00:00:00Z",
      "name": "My ruleset",
      "phase": "http_request_firewall_custom",
      "version": "1",
      "description": "A description for my ruleset."
    }
  ],
  "success": true,
  "result_info": {
    "cursors": {
      "after": "dGhpc2lzYW5leGFtcGxlCg"
    }
  }
}
```

##### Returns Examples

200 example

```
{
  "errors": [
    {
      "message": "something bad happened",
      "code": 10000,
      "source": {
        "pointer": "/rules/0/action"
      }
    }
  ],
  "messages": [
    {
      "message": "something bad happened",
      "code": 10000,
      "source": {
        "pointer": "/rules/0/action"
      }
    }
  ],
  "result": [
    {
      "id": "2f2feab2026849078ba485f918791bdc",
      "kind": "root",
      "last_updated": "2000-01-01T00:00:00Z",
      "name": "My ruleset",
      "phase": "http_request_firewall_custom",
      "version": "1",
      "description": "A description for my ruleset."
    }
  ],
  "success": true,
  "result_info": {
    "cursors": {
      "after": "dGhpc2lzYW5leGFtcGxlCg"
    }
  }
}
```