Requires Node.js 14+
Installation
Install the@sendsculpt/sdk npm package:
Copy
Ask AI
npm install @sendsculpt/sdk
Quick Start
Initialize the client with your API Key.Copy
Ask AI
const SendSculptClient = require("@sendsculpt/sdk");
const client = new SendSculptClient("your-api-key");
async function triggerEmail() {
try {
const response = await client.sendEmail({
to: ["recipient@example.com"],
subject: "Welcome to SendSculpt!",
fromEmail: "noreply@yourdomain.com",
bodyHtml: "<p>Hello! This is a test email from the SendSculpt Node.js SDK.</p>"
});
console.log("Success:", response);
} catch (error) {
console.error("Failed to send:", error.message);
}
}
triggerEmail();
Advanced Usage
Send emails utilizing SendSculpt Templates and auto-encoded Attachments.Copy
Ask AI
const SendSculptClient = require("@sendsculpt/sdk");
const client = new SendSculptClient("your-api-key");
async function sendMonthlyInvoice() {
try {
const response = await client.sendEmail({
to: ["john@doe.com"],
subject: "Your Monthly Invoice",
fromEmail: "billing@yourdomain.com",
templateId: "your-template-uuid",
templateData: {
first_name: "John",
invoice_amount: "49.99"
},
cc: ["finance@yourdomain.com"],
attachments: [
{
filename: "invoice.pdf",
filePath: "/path/to/invoice.pdf", // Automatically converted to base64
mime_type: "application/pdf"
}
]
});
console.log("Email queued successfully. Message ID:", response.message_id);
} catch (error) {
console.error(error.message);
}
}
sendMonthlyInvoice();
For local testing or proxy implementations, you can specify a custom
baseUrl as the second argument during client initialization: new SendSculptClient('local-api-key', 'https://api.sendsculpt.com/api/v1');.