---
title: "Create or update a snippet"
method: PUT
path: "/api/snippets/{identifier}"
tags: ["snippets"]
---

# Create or update a snippet

`PUT /api/snippets/{identifier}`

Create or update a snippet by ID (numeric) or name (string). For names, creates the snippet if it doesn't exist. For IDs, only updates existing snippets. Numeric identifiers are treated as IDs, string identifiers as names.

## Path parameters

- `identifier` string, required

## Request body

- UpdateSnippetRequest — Request model for updating a snippet
  - `content` string, required — Content of the snippet. Handlebars must be valid. Disallowed content: script tags with JS sources or non-JSON content, inline JS event handlers (e.g., <code>onload=&quot;...&quot;</code>), and <code>javascript:</code> in <code>href</code> or <code>src</code> attributes (anchors and iframes).
  - `createdByUserId` string — User ID (email) of the updater. If not provided, defaults to the project creator.
  - `description` string — Description of the snippet.
  - `variables` string[] — List of variable names used in the content with a Handlebars expression such as {{myField}}. Variable names are case-sensitive and should be simple identifiers (letters, numbers, underscores). To learn more about using Handlebars in Snippets, see <a href=\"https://support.iterable.com/hc/articles/4414796078868\">Customizing Snippets with Variables</a>.

## Response `200`

Snippet updated successfully

## Other responses

- `201` — Snippet created successfully
- `400` — Invalid request parameters
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Snippet not found (for ID-based identifiers)
- `500` — Internal server error

---

[API](https://skmtc.net/iterable/apis/iterable-api.md) · [All operations](https://skmtc.net/iterable/apis/iterable-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/iterable/iterable-api/revisions/afaab604b58c/schema)
