---
title: "Create a snippet"
method: POST
path: "/api/snippets"
tags: ["snippets"]
---

# Create a snippet

`POST /api/snippets`

Create a new snippet.

## Request body

- CreateSnippetRequest — Request model for creating 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 creator. If not provided, defaults to the project creator.
  - `description` string — Description of the snippet.
  - `name` string, required — Name of the snippet. Must be unique within the project, up to 100 characters (a-z, A-Z, 0-9, hyphens (-), underscores (_), and spaces). Cannot be changed after snippet is created.
  - `variables` string[] — A list of variable names used in the content with a Handlebars expression such as <code>{{#if (eq myVariable "someValue")}}</code>. Variable names are case-sensitive and should be simple identifiers (letters, numbers, underscores). To learn more about using variables in Snippets, see <a href=\"https://support.iterable.com/hc/articles/4414796078868\">Customizing Snippets with Variables</a>.

## Response `200`

successful operation

## Other responses

- `201` — Snippet created successfully
- `400` — Invalid request parameters
- `401` — Unauthorized
- `403` — Forbidden
- `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)
