Skip to content
Start here

List zone snippets

GET/zones/{zone_id}/snippets

Fetches all snippets belonging to the zone.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

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

Example:X-Auth-Email: user@example.com

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

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Snippets WriteSnippets Read
Path ParametersExpand Collapse
zone_id: string

Use this field to specify the unique ID of the zone.

Query ParametersExpand Collapse
page: optional number

Specifies the current page number.

minimum1
per_page: optional number

Specifies how many results to return per page.

minimum1
ReturnsExpand Collapse
errors: array of object { message, code }

Lists error messages.

message: string

Describes the message text.

minLength1
code: optional number

Identify the message code.

messages: array of object { message, code }

Contain warning messages.

message: string

Describes the message text.

minLength1
code: optional number

Identify the message code.

result: array of object { created_on, snippet_name, modified_on }

Contain snippets.

created_on: string

Indicates when the snippet was created.

formatdate-time
snippet_name: string

Identify the snippet.

modified_on: optional string

Indicates when the snippet was last modified.

formatdate-time
success: true

Indicate whether the API call was successful.

result_info: optional object { count, page, per_page, 2 more }

Additional information to navigate the results.

count: number

Specify the number of results in the current page.

minimum0
page: number

Specifies the current page number.

minimum1
per_page: number

Specifies how many results to return per page.

minimum1
total_count: number

Specify the total number of results.

minimum0
total_pages: number

Specify the total number of pages.

minimum1

List zone snippets

curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/snippets \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{
  "errors": [
    {
      "message": "something bad happened",
      "code": 10000
    }
  ],
  "messages": [
    {
      "message": "something bad happened",
      "code": 10000
    }
  ],
  "result": [
    {
      "created_on": "2000-01-01T00:00:00.000000Z",
      "snippet_name": "my_snippet",
      "modified_on": "2000-01-01T00:00:00.000000Z"
    }
  ],
  "success": true,
  "result_info": {
    "count": 25,
    "page": 1,
    "per_page": 25,
    "total_count": 100,
    "total_pages": 10
  }
}
Returns Examples
{
  "errors": [
    {
      "message": "something bad happened",
      "code": 10000
    }
  ],
  "messages": [
    {
      "message": "something bad happened",
      "code": 10000
    }
  ],
  "result": [
    {
      "created_on": "2000-01-01T00:00:00.000000Z",
      "snippet_name": "my_snippet",
      "modified_on": "2000-01-01T00:00:00.000000Z"
    }
  ],
  "success": true,
  "result_info": {
    "count": 25,
    "page": 1,
    "per_page": 25,
    "total_count": 100,
    "total_pages": 10
  }
}