Get a snippet
curl --request GET \
--url https://api.kit.com/v4/snippets/{id} \
--header 'X-Kit-Api-Key: <api-key>'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/snippets/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
response = http.request(request)
puts response.read_bodyconst options = {method: 'GET', headers: {'X-Kit-Api-Key': '<api-key>'}};
fetch('https://api.kit.com/v4/snippets/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/snippets/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Kit-Api-Key", "<api-key>")
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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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/{id}"
headers = {"X-Kit-Api-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text){
"snippet": {
"id": 24,
"name": "Welcome message",
"snippet_type": "inline",
"archived": false,
"key": "welcome-message",
"created_at": "2023-02-17T11:43:55Z",
"updated_at": "2023-02-17T11:43:55Z",
"content": "Hello {{ subscriber.first_name }}",
"document": {
"id": 311,
"value": null,
"value_html": "content",
"value_plain": null,
"version": 1
}
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"Not Found"
]
}Snippets
Get a snippet
Fetches a single snippet by id. Unlike List snippets, this endpoint always returns the full content and document — no include_content flag needed.
Use this when you have an id (e.g. stored from a prior create call) and need the current key and body — for example, to preview the resolved HTML or confirm a snippet still exists before referencing it as {{ snippet.key }} in a broadcast or sequence email. See Create a snippet for the snippet model.
GET
/
v4
/
snippets
/
{id}
Get a snippet
curl --request GET \
--url https://api.kit.com/v4/snippets/{id} \
--header 'X-Kit-Api-Key: <api-key>'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/snippets/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
response = http.request(request)
puts response.read_bodyconst options = {method: 'GET', headers: {'X-Kit-Api-Key': '<api-key>'}};
fetch('https://api.kit.com/v4/snippets/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/snippets/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Kit-Api-Key", "<api-key>")
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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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/{id}"
headers = {"X-Kit-Api-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text){
"snippet": {
"id": 24,
"name": "Welcome message",
"snippet_type": "inline",
"archived": false,
"key": "welcome-message",
"created_at": "2023-02-17T11:43:55Z",
"updated_at": "2023-02-17T11:43:55Z",
"content": "Hello {{ subscriber.first_name }}",
"document": {
"id": 311,
"value": null,
"value_html": "content",
"value_plain": null,
"version": 1
}
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"Not Found"
]
}Was this page helpful?
⌘I