Create a new snippet
curl --request POST \
--url https://www.getsnippets.ai/api/prompts/snippet \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "My API Snippet",
"content": {
"type": "plaintext",
"content": "Hello, world!"
},
"teamId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>",
"shortcut": "<string>",
"folderId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tagIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"additionalVariations": [
{
"content": {
"type": "plaintext",
"content": "Hello, world!"
},
"variationName": "Spanish Version"
}
]
}
'import requests
url = "https://www.getsnippets.ai/api/prompts/snippet"
payload = {
"title": "My API Snippet",
"content": {
"type": "plaintext",
"content": "Hello, world!"
},
"teamId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>",
"shortcut": "<string>",
"folderId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tagIds": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"additionalVariations": [
{
"content": {
"type": "plaintext",
"content": "Hello, world!"
},
"variationName": "Spanish Version"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: 'My API Snippet',
content: {type: 'plaintext', content: 'Hello, world!'},
teamId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
note: '<string>',
shortcut: '<string>',
folderId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
tagIds: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
additionalVariations: [
{
content: {type: 'plaintext', content: 'Hello, world!'},
variationName: 'Spanish Version'
}
]
})
};
fetch('https://www.getsnippets.ai/api/prompts/snippet', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.getsnippets.ai/api/prompts/snippet",
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([
'title' => 'My API Snippet',
'content' => [
'type' => 'plaintext',
'content' => 'Hello, world!'
],
'teamId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'note' => '<string>',
'shortcut' => '<string>',
'folderId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'tagIds' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'additionalVariations' => [
[
'content' => [
'type' => 'plaintext',
'content' => 'Hello, world!'
],
'variationName' => 'Spanish Version'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.getsnippets.ai/api/prompts/snippet"
payload := strings.NewReader("{\n \"title\": \"My API Snippet\",\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"teamId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"note\": \"<string>\",\n \"shortcut\": \"<string>\",\n \"folderId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"tagIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"additionalVariations\": [\n {\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"variationName\": \"Spanish Version\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://www.getsnippets.ai/api/prompts/snippet")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"My API Snippet\",\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"teamId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"note\": \"<string>\",\n \"shortcut\": \"<string>\",\n \"folderId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"tagIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"additionalVariations\": [\n {\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"variationName\": \"Spanish Version\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.getsnippets.ai/api/prompts/snippet")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"My API Snippet\",\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"teamId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"note\": \"<string>\",\n \"shortcut\": \"<string>\",\n \"folderId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"tagIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"additionalVariations\": [\n {\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"variationName\": \"Spanish Version\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"snippetId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"usage": {
"remainingRequests": 123
},
"metadata": {
"totalVariations": 123,
"tagsAttached": 123
}
}Snippets
Create Snippet
Creates a new snippet with optional variations and tags. API Cost: 1 request.
POST
/
snippet
Create a new snippet
curl --request POST \
--url https://www.getsnippets.ai/api/prompts/snippet \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "My API Snippet",
"content": {
"type": "plaintext",
"content": "Hello, world!"
},
"teamId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>",
"shortcut": "<string>",
"folderId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tagIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"additionalVariations": [
{
"content": {
"type": "plaintext",
"content": "Hello, world!"
},
"variationName": "Spanish Version"
}
]
}
'import requests
url = "https://www.getsnippets.ai/api/prompts/snippet"
payload = {
"title": "My API Snippet",
"content": {
"type": "plaintext",
"content": "Hello, world!"
},
"teamId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>",
"shortcut": "<string>",
"folderId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tagIds": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"additionalVariations": [
{
"content": {
"type": "plaintext",
"content": "Hello, world!"
},
"variationName": "Spanish Version"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: 'My API Snippet',
content: {type: 'plaintext', content: 'Hello, world!'},
teamId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
note: '<string>',
shortcut: '<string>',
folderId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
tagIds: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
additionalVariations: [
{
content: {type: 'plaintext', content: 'Hello, world!'},
variationName: 'Spanish Version'
}
]
})
};
fetch('https://www.getsnippets.ai/api/prompts/snippet', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.getsnippets.ai/api/prompts/snippet",
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([
'title' => 'My API Snippet',
'content' => [
'type' => 'plaintext',
'content' => 'Hello, world!'
],
'teamId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'note' => '<string>',
'shortcut' => '<string>',
'folderId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'tagIds' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'additionalVariations' => [
[
'content' => [
'type' => 'plaintext',
'content' => 'Hello, world!'
],
'variationName' => 'Spanish Version'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.getsnippets.ai/api/prompts/snippet"
payload := strings.NewReader("{\n \"title\": \"My API Snippet\",\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"teamId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"note\": \"<string>\",\n \"shortcut\": \"<string>\",\n \"folderId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"tagIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"additionalVariations\": [\n {\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"variationName\": \"Spanish Version\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://www.getsnippets.ai/api/prompts/snippet")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"My API Snippet\",\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"teamId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"note\": \"<string>\",\n \"shortcut\": \"<string>\",\n \"folderId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"tagIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"additionalVariations\": [\n {\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"variationName\": \"Spanish Version\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.getsnippets.ai/api/prompts/snippet")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"My API Snippet\",\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"teamId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"note\": \"<string>\",\n \"shortcut\": \"<string>\",\n \"folderId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"tagIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"additionalVariations\": [\n {\n \"content\": {\n \"type\": \"plaintext\",\n \"content\": \"Hello, world!\"\n },\n \"variationName\": \"Spanish Version\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"snippetId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"usage": {
"remainingRequests": 123
},
"metadata": {
"totalVariations": 123,
"tagsAttached": 123
}
}Overview
Creates a new snippet with optional variations, folder assignment, and tags. This endpoint allows you to create structured snippets programmatically. API Cost: 1 requestCode Examples
const axios = require('axios');
const API_KEY = process.env.SNIPPETS_AI_API_KEY;
const BASE_URL = 'https://www.getsnippets.ai/api/prompts';
async function createSnippet(snippetData) {
try {
const response = await axios.post(`${BASE_URL}/snippet`, snippetData, {
headers: {
Authorization: `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
});
console.log('Created snippet ID:', response.data.data.snippetId);
console.log('Remaining requests:', response.data.usage.remainingRequests);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
}
// Basic snippet
const basicSnippet = {
title: 'My API Snippet',
content: {
type: 'plaintext',
content: "console.log('Hello, World!');",
},
teamId: 'your-team-id',
};
createSnippet(basicSnippet);
// Snippet with all optional fields
const fullSnippet = {
title: 'Customer Onboarding Email',
content: {
type: 'plaintext',
content: 'Dear {{customer_name}},\n\nWelcome to our platform!',
},
teamId: 'your-team-id',
note: 'Use this template for new customer onboarding',
shortcut: 'welcome_email',
folderId: 'folder-uuid',
tagIds: ['tag-uuid-1', 'tag-uuid-2'],
additionalVariations: [
{
content: {
type: 'plaintext',
content: 'Hola {{customer_name}},\n\n¡Bienvenido!',
},
variationName: 'Spanish Version',
},
{
content: {
type: 'plaintext',
content: 'Bonjour {{customer_name}},\n\nBienvenue!',
},
variationName: 'French Version',
},
],
};
createSnippet(fullSnippet);
import os
import requests
API_KEY = os.environ.get('SNIPPETS_AI_API_KEY')
BASE_URL = 'https://www.getsnippets.ai/api/prompts'
def create_snippet(snippet_data):
try:
response = requests.post(
f'{BASE_URL}/snippet',
headers={
'Authorization': f'Bearer {API_KEY}',
'Content-Type': 'application/json'
},
json=snippet_data
)
response.raise_for_status()
data = response.json()
print(f"Created snippet ID: {data['data']['snippetId']}")
print(f"Remaining requests: {data['usage']['remainingRequests']}")
return data
except requests.exceptions.HTTPError as e:
print(f"Error: {e.response.json().get('message')}")
raise
# Basic snippet
basic_snippet = {
'title': 'My API Snippet',
'content': {
'type': 'plaintext',
'content': 'print("Hello, World!")'
},
'teamId': 'your-team-id'
}
create_snippet(basic_snippet)
curl -X POST "https://www.getsnippets.ai/api/prompts/snippet" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "My API Snippet",
"content": {
"type": "plaintext",
"content": "Hello, World!"
},
"teamId": "your-team-id",
"note": "Created via API",
"folderId": "folder-uuid",
"tagIds": ["tag-uuid-1"]
}'
Real-World Use Case: Voice AI Integration
Here’s a complete example of creating prompts for a voice AI system (like VAPI):async function createVoiceAgentPrompts(clientData) {
const { clientName, industry, teamId, folderId } = clientData;
// Create a snippet with multiple language variations
const snippet = {
title: `${clientName} - ${industry} Agent`,
content: {
type: 'plaintext',
content: `You are a professional ${industry} assistant for ${clientName}.
Your role is to help customers with inquiries, schedule appointments,
and provide information about services. Be polite, professional, and helpful.`,
},
teamId: teamId,
folderId: folderId,
note: `Voice agent prompt for ${clientName}`,
shortcut: `${clientName.toLowerCase()}_agent`,
tagIds: [industryTagId, voiceAgentTagId],
additionalVariations: [
{
content: {
type: 'plaintext',
content: `Eres un asistente profesional de ${industry} para ${clientName}.
Tu función es ayudar a los clientes con consultas, programar citas
y proporcionar información sobre servicios. Sé cortés, profesional y servicial.`,
},
variationName: 'Spanish Version',
},
{
content: {
type: 'plaintext',
content: `You are handling after-hours calls for ${clientName}.
Inform customers of business hours and offer to schedule a callback
during office hours. Be understanding and helpful.`,
},
variationName: 'After Hours',
},
],
};
try {
const response = await createSnippet(snippet);
console.log(`✅ Created voice agent prompt: ${response.data.snippetId}`);
console.log(` Variations: ${response.data.metadata.totalVariations}`);
return response.data.snippetId;
} catch (error) {
console.error(
`❌ Failed to create prompt for ${clientName}:`,
error.message
);
throw error;
}
}
// Usage
createVoiceAgentPrompts({
clientName: 'Dental Clinic ABC',
industry: 'Healthcare',
teamId: 'healthcare-team-id',
folderId: 'dental-clients-folder-id',
});
Response Example
{
"success": true,
"data": {
"snippetId": "550e8400-e29b-41d4-a716-446655440000"
},
"usage": {
"remainingRequests": 99999
},
"metadata": {
"totalVariations": 3,
"tagsAttached": 2
}
}
Validation Rules
string
required
Length: 1-200 characters Cannot be empty or exceed 200 characters.
object
required
Must include
type and content fields.{
"type": "plaintext",
"content": "Your content here"
}
string
required
Must be a valid team ID that your API key has access to.
string
Length: 0-5000 characters (optional)
string
Length: 0-100 characters (optional)
string
Must be a valid folder ID in the same team (optional)
array
Array of valid tag IDs from the same team (optional)
Batch Creation
To create multiple snippets, use the batch endpoint instead:// Instead of this (inefficient):
for (const snippetData of snippets) {
await createSnippet(snippetData); // N API calls + N * rate limit issues
}
// Do this (efficient):
await createSnippets({ snippets }); // 1 API call, N request cost
Error Handling
async function createSnippetSafe(snippetData) {
// Pre-validate before API call
if (!snippetData.title || snippetData.title.length === 0) {
throw new Error('Title is required');
}
if (snippetData.title.length > 200) {
throw new Error('Title cannot exceed 200 characters');
}
if (!snippetData.content) {
throw new Error('Content is required');
}
if (!snippetData.teamId) {
throw new Error('Team ID is required');
}
if (snippetData.note && snippetData.note.length > 5000) {
throw new Error('Note cannot exceed 5000 characters');
}
try {
return await createSnippet(snippetData);
} catch (error) {
const status = error.response?.status;
const message = error.response?.data?.message;
if (status === 400) {
throw new Error(`Validation error: ${message}`);
} else if (status === 403) {
if (message?.includes('team')) {
throw new Error('API key does not have access to this team');
} else if (message?.includes('folder')) {
throw new Error('Folder not found or not accessible');
} else if (message?.includes('tag')) {
throw new Error('One or more tags not found');
}
}
throw error;
}
}
Best Practices
Validate data before API calls to catch errors early and save on API costs
Use meaningful titles that make snippets easy to identify
Add notes to provide context for team members
Organize with folders and tags for better management
Create variations for different use cases (languages, contexts, etc.)
Always verify that folder IDs and tag IDs exist and belong to the correct team
before creating snippets.
Related Endpoints
- Update Snippet - Update an existing snippet
- Create Multiple Snippets - Batch create snippets
- Get Snippet - Retrieve a snippet
- Create Folder - Create a folder first
Authorizations
API key authentication using Bearer token. Include your API key in the Authorization header.
Body
application/json
Title of the snippet
Maximum string length:
200Example:
"My API Snippet"
Show child attributes
Show child attributes
ID of the team this snippet belongs to
Optional note for the snippet
Maximum string length:
5000Optional keyboard shortcut
Maximum string length:
100Optional folder ID to organize the snippet
Optional array of tag IDs
Optional additional variations of this snippet
Show child attributes
Show child attributes
⌘I