Snippets
Versioned text files served at /snippets/<path>?v=<n> on the website’s domain. Use for reusable code and data referenced from pages — CSS stylesheets, JavaScript, JSON configs, SVG icons, HTML partials.
For binary files (images, fonts, video, PDFs), use assets instead.
Actions
list_snippets
List all snippets for a website.
Parameters:
website— Website subdomain, domain, or UUID
get_snippet
Get a snippet’s content, content_type, and version info. Always call before editing to get the exact current content.
Parameters:
website— Website subdomain, domain, or UUIDpath— Snippet path (e.g.css/style.css)version_number— Optional specific version number
create_snippet
Create a new text snippet. content_type is inferred from the file extension if omitted.
Parameters:
website— Website subdomain, domain, or UUIDpath— Relative path under/snippets/, no leading slash (e.g.css/style.css,js/app.js)content— File content (max 256 KB)content_type— Optional MIME type (inferred from extension when omitted)
update_snippet
Update a snippet’s content. Creates a new version unless content is unchanged (skip-unchanged).
Parameters:
website— Website subdomain, domain, or UUIDpath— Snippet pathcontent— Full content to overwrite (mutually exclusive withreplacements)replacements— Array of find-and-replace operations (max 10). Each:{ old_html, new_html, mode }where mode isreplace(default),replace_all, orappenddry_run— Validate without creating a version
delete_snippet
Delete a snippet and all its versions permanently. Requires user confirmation.
Parameters:
website— Website subdomain, domain, or UUIDpath— Snippet path
Path Rules
- Relative path, no leading slash (
css/style.css, not/css/style.css) - Lowercase alphanumeric, dashes, underscores, slashes
- One extension dot per path segment
- Max 256 KB per version
Content Type Inference
When content_type is omitted, it’s inferred from the file extension:
| Extension | Content Type |
|---|---|
.css |
text/css |
.js |
text/javascript |
.json |
application/json |
.svg |
image/svg+xml |
.html |
text/html |
.md |
text/markdown |
.xml |
application/xml |
.csv |
text/csv |
.yaml / .yml |
application/yaml |
.txt |
text/plain |
.webmanifest |
application/manifest+json |
Provide content_type explicitly for extensionless paths.
Versioning
Snippets are versioned like pages. Every update_snippet call creates a new version unless the content is identical (skip-unchanged).
- Pin a specific version:
pin_version(target: "snippet:css/style.css", version_number: 3) - Revert to a previous version:
revert_version(target: "snippet:css/style.css", version_number: 2)
Usage in Pages
Reference snippets from page HTML using the relative_url returned by create/get/list:
<link rel="stylesheet" href="/snippets/css/style.css?v=1">
<script src="/snippets/js/app.js?v=1"></script>
<img src="/snippets/icons/logo.svg?v=1" alt="Logo">
The ?v=<n> query param cache-busts when the snippet is updated.
OAuth Scopes
| Action | Scope |
|---|---|
| list, get | snippet:read |
| create, update | snippet:write |
| delete | snippet:delete |