Retrieves a single snippet by its ID. This endpoint returns the complete snippet data including content, metadata, folder assignment, and timestamps.API Cost: 1 request
Retrieve a specific prompt variation for use in voice AI services like VAPI:
Copy
async function getPromptForVoiceAgent(snippetId) { const response = await getSnippet(snippetId); const promptContent = response.data.content.content; // Use with VAPI or similar service const vapiCall = await initiateVoiceCall({ systemPrompt: promptContent, phoneNumber: customerPhone }); return vapiCall;}
Display in Application UI
Fetch snippet data to display in your application:
async function getSnippetSafely(snippetId) { try { return await getSnippet(snippetId); } catch (error) { const status = error.response?.status; const message = error.response?.data?.message; switch (status) { case 400: throw new Error(`Invalid request: ${message}`); case 401: throw new Error('Invalid API key - check your authentication'); case 403: throw new Error('Access denied - check team permissions'); case 404: throw new Error(`Snippet ${snippetId} not found`); case 429: const retryAfter = error.response.headers['retry-after']; throw new Error(`Rate limit exceeded. Retry after ${retryAfter}s`); default: throw new Error(`API error: ${message || 'Unknown error'}`); } }}
Problem: The snippet ID doesn’t exist or was deleted.Solution:
Verify the snippet ID is correct
Check if the snippet was deleted
Ensure the snippet belongs to your workspace
403 Forbidden
Problem: Your API key doesn’t have access to the snippet’s team.
Solution: - Check your API key’s team permissions - Ensure the API key has
access to the required team - Verify your workspace subscription is active
401 Unauthorized
Problem: Invalid or missing API key.Solution:
Check the Authorization header is properly formatted