> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendsculpt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js

> SendSculpt JavaScript & TypeScript official client.

<Note>Requires Node.js 14+</Note>

## Installation

Install the `@sendsculpt/client` npm package:

```bash theme={null}
npm install @sendsculpt/client
```

## Quick Start

Initialize the client with your **[API Key](https://sendsculpt.com/settings)**.

```javascript theme={null}
const { SendSculptClient } = require("@sendsculpt/client");

const client = new SendSculptClient("your_secret_api_key_here");

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**.

```javascript theme={null}
const { SendSculptClient } = require("@sendsculpt/client");

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();
```

<Tip>
  The SendSculpt API automatically handles environments based on your API key. Use a Sandbox key for testing and a Live key for
  production.
</Tip>
