---
title: Snippets
---

[Skip to content](#_top)

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

Copy Markdown

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

---

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

# Snippets

##### [List zone snippets](https://developers.cloudflare.com/api/typescript/resources/snippets/methods/list)

client.snippets.list(SnippetListParams {zone\_id, page, per\_page } params, RequestOptionsoptions?): V4PagePaginationArray< [SnippetListResponse](<https://developers.cloudflare.com/api/typescript/resources/snippets#(resource)%20snippets%20%3E%20(model)%20snippet_list_response%20%3E%20(schema)>) {created\_on, snippet\_name, modified\_on } >

GET/zones/{zone\_id}/snippets

##### [Get a zone snippet](https://developers.cloudflare.com/api/typescript/resources/snippets/methods/get)

client.snippets.get(stringsnippetName, SnippetGetParams {zone\_id } params, RequestOptionsoptions?): [SnippetGetResponse](<https://developers.cloudflare.com/api/typescript/resources/snippets#(resource)%20snippets%20%3E%20(model)%20snippet_get_response%20%3E%20(schema)>) {created\_on, snippet\_name, modified\_on }

GET/zones/{zone\_id}/snippets/{snippet\_name}

##### [Update a zone snippet](https://developers.cloudflare.com/api/typescript/resources/snippets/methods/update)

client.snippets.update(stringsnippetName, SnippetUpdateParams {zone\_id, metadata } params, RequestOptionsoptions?): [SnippetUpdateResponse](<https://developers.cloudflare.com/api/typescript/resources/snippets#(resource)%20snippets%20%3E%20(model)%20snippet_update_response%20%3E%20(schema)>) {created\_on, snippet\_name, modified\_on }

PUT/zones/{zone\_id}/snippets/{snippet\_name}

##### [Delete a zone snippet](https://developers.cloudflare.com/api/typescript/resources/snippets/methods/delete)

client.snippets.delete(stringsnippetName, SnippetDeleteParams {zone\_id } params, RequestOptionsoptions?): [SnippetDeleteResponse](<https://developers.cloudflare.com/api/typescript/resources/snippets#(resource)%20snippets%20%3E%20(model)%20snippet_delete_response%20%3E%20(schema)>)| null

DELETE/zones/{zone\_id}/snippets/{snippet\_name}

##### ModelsExpand Collapse

<details>

<summary>

SnippetListResponse {created\_on, snippet\_name, modified\_on }

Define a snippet.

</summary>

created\_on: string

Indicates when the snippet was created.

formatdate-time

<a href="#(resource)%20snippets%20%3E%20(model)%20snippet_list_response%20%3E%20(schema)%20%3E%20(property)%20created_on">Link to this property</a>

snippet\_name: string

Identify the snippet.

<a href="#(resource)%20snippets%20%3E%20(model)%20snippet_list_response%20%3E%20(schema)%20%3E%20(property)%20snippet_name">Link to this property</a>

modified\_on?: string

Indicates when the snippet was last modified.

formatdate-time

<a href="#(resource)%20snippets%20%3E%20(model)%20snippet_list_response%20%3E%20(schema)%20%3E%20(property)%20modified_on">Link to this property</a>

</details>

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

<details>

<summary>

SnippetGetResponse {created\_on, snippet\_name, modified\_on }

Define a snippet.

</summary>

created\_on: string

Indicates when the snippet was created.

formatdate-time

<a href="#(resource)%20snippets%20%3E%20(model)%20snippet_get_response%20%3E%20(schema)%20%3E%20(property)%20created_on">Link to this property</a>

snippet\_name: string

Identify the snippet.

<a href="#(resource)%20snippets%20%3E%20(model)%20snippet_get_response%20%3E%20(schema)%20%3E%20(property)%20snippet_name">Link to this property</a>

modified\_on?: string

Indicates when the snippet was last modified.

formatdate-time

<a href="#(resource)%20snippets%20%3E%20(model)%20snippet_get_response%20%3E%20(schema)%20%3E%20(property)%20modified_on">Link to this property</a>

</details>

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

<details>

<summary>

SnippetUpdateResponse {created\_on, snippet\_name, modified\_on }

Define a snippet.

</summary>

created\_on: string

Indicates when the snippet was created.

formatdate-time

<a href="#(resource)%20snippets%20%3E%20(model)%20snippet_update_response%20%3E%20(schema)%20%3E%20(property)%20created_on">Link to this property</a>

snippet\_name: string

Identify the snippet.

<a href="#(resource)%20snippets%20%3E%20(model)%20snippet_update_response%20%3E%20(schema)%20%3E%20(property)%20snippet_name">Link to this property</a>

modified\_on?: string

Indicates when the snippet was last modified.

formatdate-time

<a href="#(resource)%20snippets%20%3E%20(model)%20snippet_update_response%20%3E%20(schema)%20%3E%20(property)%20modified_on">Link to this property</a>

</details>

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

SnippetDeleteResponse = unknown

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

#### SnippetsContent

##### [Get a zone snippet content](https://developers.cloudflare.com/api/typescript/resources/snippets/subresources/content/methods/get)

client.snippets.content.get(stringsnippetName, ContentGetParams {zone\_id } params, RequestOptionsoptions?): Response

GET/zones/{zone\_id}/snippets/{snippet\_name}/content

#### SnippetsRules

##### [List zone snippet rules](https://developers.cloudflare.com/api/typescript/resources/snippets/subresources/rules/methods/get)

client.snippets.rules.get(RuleGetParams {zone\_id } params, RequestOptionsoptions?): SinglePage< [RuleGetResponse](<https://developers.cloudflare.com/api/typescript/resources/snippets#(resource)%20snippets.rules%20%3E%20(model)%20rule_get_response%20%3E%20(schema)>) {id, expression, last\_updated, 3 more } >

GET/zones/{zone\_id}/snippets/snippet\_rules

##### [List zone snippet rules](https://developers.cloudflare.com/api/typescript/resources/snippets/subresources/rules/methods/list)

client.snippets.rules.list(RuleListParams {zone\_id } params, RequestOptionsoptions?): SinglePage< [RuleListResponse](<https://developers.cloudflare.com/api/typescript/resources/snippets#(resource)%20snippets.rules%20%3E%20(model)%20rule_list_response%20%3E%20(schema)>) {id, expression, last\_updated, 3 more } >

GET/zones/{zone\_id}/snippets/snippet\_rules

##### [Update zone snippet rules](https://developers.cloudflare.com/api/typescript/resources/snippets/subresources/rules/methods/update)

client.snippets.rules.update(RuleUpdateParams {zone\_id, rules } params, RequestOptionsoptions?): SinglePage< [RuleUpdateResponse](<https://developers.cloudflare.com/api/typescript/resources/snippets#(resource)%20snippets.rules%20%3E%20(model)%20rule_update_response%20%3E%20(schema)>) {id, expression, last\_updated, 3 more } >

PUT/zones/{zone\_id}/snippets/snippet\_rules

##### [Delete zone snippet rules](https://developers.cloudflare.com/api/typescript/resources/snippets/subresources/rules/methods/delete)

client.snippets.rules.delete(RuleDeleteParams {zone\_id } params, RequestOptionsoptions?): SinglePage< [RuleDeleteResponse](<https://developers.cloudflare.com/api/typescript/resources/snippets#(resource)%20snippets.rules%20%3E%20(model)%20rule_delete_response%20%3E%20(schema)>) {id, expression, last\_updated, 3 more } >

DELETE/zones/{zone\_id}/snippets/snippet\_rules

##### ModelsExpand Collapse

<details>

<summary>

RuleGetResponse {id, expression, last\_updated, 3 more }

Define a snippet rule.

</summary>

id: string

Specify the unique ID of the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_get_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

expression: string

Define the expression that determines which traffic matches the rule.

minLength1

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_get_response%20%3E%20(schema)%20%3E%20(property)%20expression">Link to this property</a>

last\_updated: string

Specify the timestamp of when the rule was last modified.

formatdate-time

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_get_response%20%3E%20(schema)%20%3E%20(property)%20last_updated">Link to this property</a>

snippet\_name: string

Identify the snippet.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_get_response%20%3E%20(schema)%20%3E%20(property)%20snippet_name">Link to this property</a>

description?: string

Provide an informative description of the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_get_response%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

enabled?: boolean

Indicate whether to execute the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_get_response%20%3E%20(schema)%20%3E%20(property)%20enabled">Link to this property</a>

</details>

[Link to this property](<#(resource)%20snippets.rules%20%3E%20(model)%20rule_get_response%20%3E%20(schema)>)

<details>

<summary>

RuleListResponse {id, expression, last\_updated, 3 more }

Define a snippet rule.

</summary>

id: string

Specify the unique ID of the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_list_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

expression: string

Define the expression that determines which traffic matches the rule.

minLength1

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_list_response%20%3E%20(schema)%20%3E%20(property)%20expression">Link to this property</a>

last\_updated: string

Specify the timestamp of when the rule was last modified.

formatdate-time

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_list_response%20%3E%20(schema)%20%3E%20(property)%20last_updated">Link to this property</a>

snippet\_name: string

Identify the snippet.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_list_response%20%3E%20(schema)%20%3E%20(property)%20snippet_name">Link to this property</a>

description?: string

Provide an informative description of the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_list_response%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

enabled?: boolean

Indicate whether to execute the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_list_response%20%3E%20(schema)%20%3E%20(property)%20enabled">Link to this property</a>

</details>

[Link to this property](<#(resource)%20snippets.rules%20%3E%20(model)%20rule_list_response%20%3E%20(schema)>)

<details>

<summary>

RuleUpdateResponse {id, expression, last\_updated, 3 more }

Define a snippet rule.

</summary>

id: string

Specify the unique ID of the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_update_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

expression: string

Define the expression that determines which traffic matches the rule.

minLength1

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_update_response%20%3E%20(schema)%20%3E%20(property)%20expression">Link to this property</a>

last\_updated: string

Specify the timestamp of when the rule was last modified.

formatdate-time

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_update_response%20%3E%20(schema)%20%3E%20(property)%20last_updated">Link to this property</a>

snippet\_name: string

Identify the snippet.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_update_response%20%3E%20(schema)%20%3E%20(property)%20snippet_name">Link to this property</a>

description?: string

Provide an informative description of the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_update_response%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

enabled?: boolean

Indicate whether to execute the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_update_response%20%3E%20(schema)%20%3E%20(property)%20enabled">Link to this property</a>

</details>

[Link to this property](<#(resource)%20snippets.rules%20%3E%20(model)%20rule_update_response%20%3E%20(schema)>)

<details>

<summary>

RuleDeleteResponse {id, expression, last\_updated, 3 more }

Define a snippet rule.

</summary>

id: string

Specify the unique ID of the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_delete_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

expression: string

Define the expression that determines which traffic matches the rule.

minLength1

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_delete_response%20%3E%20(schema)%20%3E%20(property)%20expression">Link to this property</a>

last\_updated: string

Specify the timestamp of when the rule was last modified.

formatdate-time

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_delete_response%20%3E%20(schema)%20%3E%20(property)%20last_updated">Link to this property</a>

snippet\_name: string

Identify the snippet.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_delete_response%20%3E%20(schema)%20%3E%20(property)%20snippet_name">Link to this property</a>

description?: string

Provide an informative description of the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_delete_response%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

enabled?: boolean

Indicate whether to execute the rule.

<a href="#(resource)%20snippets.rules%20%3E%20(model)%20rule_delete_response%20%3E%20(schema)%20%3E%20(property)%20enabled">Link to this property</a>

</details>

[Link to this property](<#(resource)%20snippets.rules%20%3E%20(model)%20rule_delete_response%20%3E%20(schema)>)