curl --request POST \
--url https://api.kit.com/v4/snippets \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '
{
"name": "Cat Fact of the Day",
"snippet_type": "inline",
"content": "Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees."
}
'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/snippets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Cat Fact of the Day\",\n \"snippet_type\": \"inline\",\n \"content\": \"Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.\"\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'POST',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Cat Fact of the Day',
snippet_type: 'inline',
content: 'Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.'
})
};
fetch('https://api.kit.com/v4/snippets', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/snippets"
payload := strings.NewReader("{\n \"name\": \"Cat Fact of the Day\",\n \"snippet_type\": \"inline\",\n \"content\": \"Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Kit-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kit.com/v4/snippets",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Cat Fact of the Day',
'snippet_type' => 'inline',
'content' => 'Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Kit-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://api.kit.com/v4/snippets"
payload = {
"name": "Cat Fact of the Day",
"snippet_type": "inline",
"content": "Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees."
}
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"snippet": {
"id": 31,
"name": "Cat Fact of the Day",
"snippet_type": "inline",
"archived": false,
"key": "cat-fact-of-the-day",
"created_at": "2026-07-28T03:02:06Z",
"updated_at": "2026-07-28T03:02:06Z",
"content": "Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.",
"document": {
"id": 318,
"value": null,
"value_html": null,
"value_plain": null,
"version": 1
}
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"name can't be blank"
]
}Create a snippet
Snippets are reusable pieces of email content you can drop into a broadcast or sequence email using Liquid: {{ snippet.key }}. Update the snippet once and every email that references it picks up the new content on next send.
There are two snippet_types. inline snippets store plain-text content (with Liquid variable support like {{ subscriber.first_name }}) in the content field. block snippets store rich-text HTML — text, lists, images, buttons — in document_attributes.value_html. A snippet’s type is fixed at creation: it cannot be changed via Update a snippet.
The response includes a key field. That’s the identifier you use in Liquid — for example, a snippet returned with "key": "welcome-message" is referenced inside a broadcast as {{ snippet.welcome-message }}. Keys are derived from the snippet name on creation.
Note: the API rejects circular references — a snippet cannot reference itself, directly or transitively — with a 422 validation error.
For end-user context on how creators build and edit snippets in the Kit UI, see the help articles on content snippets and code snippets for custom templates.
curl --request POST \
--url https://api.kit.com/v4/snippets \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '
{
"name": "Cat Fact of the Day",
"snippet_type": "inline",
"content": "Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees."
}
'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/snippets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Cat Fact of the Day\",\n \"snippet_type\": \"inline\",\n \"content\": \"Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.\"\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'POST',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Cat Fact of the Day',
snippet_type: 'inline',
content: 'Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.'
})
};
fetch('https://api.kit.com/v4/snippets', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/snippets"
payload := strings.NewReader("{\n \"name\": \"Cat Fact of the Day\",\n \"snippet_type\": \"inline\",\n \"content\": \"Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Kit-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kit.com/v4/snippets",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Cat Fact of the Day',
'snippet_type' => 'inline',
'content' => 'Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Kit-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://api.kit.com/v4/snippets"
payload = {
"name": "Cat Fact of the Day",
"snippet_type": "inline",
"content": "Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees."
}
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"snippet": {
"id": 31,
"name": "Cat Fact of the Day",
"snippet_type": "inline",
"archived": false,
"key": "cat-fact-of-the-day",
"created_at": "2026-07-28T03:02:06Z",
"updated_at": "2026-07-28T03:02:06Z",
"content": "Did you know, {{ subscriber.first_name }}? Cats can rotate their ears 180 degrees.",
"document": {
"id": 318,
"value": null,
"value_html": null,
"value_plain": null,
"version": 1
}
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"name can't be blank"
]
}Authorizations
Authenticate API requests via an API Key
Body
Response
Creates a new snippet
Show child attributes
Show child attributes
Was this page helpful?