Create a snippet in the dashboard
Last updated Apr 16, 2026 1. In the Cloudflare dashboard, go to the Snippets page. Go to Snippets ↗ 2. (Optional) If you have not created any snippets yet, select one of the snippet templates that addresses a common use case. Then, review and adjust the proposed snippet code.
To start from scratch, select Create Snippet. 3. In Snippet name, enter a descriptive name for the snippet. You cannot change the name after creating the snippet. 4. Enter the snippet's JavaScript code in the code editor. You can test how your snippet will handle incoming requests using the HTTP and Preview tabs. 5. Select Snippet rule to configure when the snippet will run. 6. Under Run this Snippet if incoming requests match, select if you wish to run the snippet only for requests that match a custom filter expression or for all incoming requests. 7. (Optional) To define a custom expression, use the Expression Builder (specifying one or more values for Field, Operator, and Value) or manually enter an expression using the Expression Editor. For more information, refer to Edit expressions in the dashboard. 8. Select Done. 9. To deploy your snippet, select Deploy. If you are not ready to deploy your snippet, open the dropdown next to Deploy and select Save as Draft.
If you are matching a hostname in your rule expression, you may be prompted to create a proxied DNS record for that hostname. Refer to Troubleshooting for more information.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/rules/snippets/create-dashboard/#page","headline":"Create a snippet in the dashboard","description":"Create Snippets in the Cloudflare dashboard.","url":"https://developers.cloudflare.com/rules/snippets/create-dashboard/","inLanguage":"en","image":"https://developers.cloudflare.com/rules/snippets/create-dashboard/og.png?v=1a7088139ba0e604","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Create Snippets using the Terraform Cloudflare provider. title: Configure Snippets using Terraform image: https://developers.cloudflare.com/rules/snippets/create-terraform/og.png?v=fd1da57a60a8b725
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/rules/llms.txt
Use this file to discover all available pages before exploring further.
Docs