import { SnackBaseClient } from '@snackbase/sdk';
const client = new SnackBaseClient({
baseUrl: 'https://api.snackbase.dev',
apiKey: 'your-api-key',
});
// List all welcome templates
const welcomeTemplates = await client.emailTemplates.list({
template_type: 'welcome'
});
// Update a template
const updated = await client.emailTemplates.update('template-id', {
subject: 'Welcome to {{app_name}}!',
html_body: `
<!DOCTYPE html>
<html>
<body>
<h1>Welcome, {{user_name}}!</h1>
<p>Thanks for joining {{app_name}}.</p>
<a href="{{verification_url}}">Verify your email</a>
</body>
</html>
`,
enabled: true
});
// Send a test email
await client.emailTemplates.sendTest('template-id', {
recipient_email: '[email protected]',
variables: {
user_name: 'John Doe',
app_name: 'MyApp',
verification_url: 'https://example.com/verify?token=abc123'
}
});
// Check send logs
const logs = await client.emailTemplates.listLogs({
template_type: 'welcome',
limit: 10
});