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

# Golang

> SendSculpt Golang official client.

<Note>Requires Go 1.18+</Note>

## Installation

Retrieve the module using `.go get`:

```bash theme={null}
go get github.com/SendSculpt/sendsculpt-sdk/golang
```

## Quick Start

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

```go theme={null}
package main

import (
	"fmt"
	"log"

	"github.com/SendSculpt/sendsculpt-sdk/golang"
)

func main() {
	client := sendsculpt.NewClient("your-api-key")

	req := &sendsculpt.SendEmailRequest{
		To:        []string{"recipient@example.com"},
		Subject:   "Welcome to SendSculpt!",
		FromEmail: "noreply@yourdomain.com",
		BodyHTML:  sendsculpt.StringPtr("<h1>Hello!</h1><p>This is a test email.</p>"),
	}

	response, err := client.SendEmail(req)
	if err != nil {
		log.Fatalf("Failed to send email: %v", err)
	}

	fmt.Printf("Email queued successfully! Message ID: %s\n", response.MessageID)
}
```

## Advanced Usage

Send emails utilizing **SendSculpt Templates** and auto-encoded **Attachments**.

```go theme={null}
package main

import (
	"fmt"
	"log"

	"github.com/SendSculpt/sendsculpt-sdk/golang"
)

func sendInvoiceEmail(client *sendsculpt.Client) {
	req := &sendsculpt.SendEmailRequest{
		To:        []string{"john@doe.com"},
		Subject:   "Your Monthly Invoice",
		FromEmail: "billing@yourdomain.com",
		TemplateID: sendsculpt.StringPtr("uuid-of-your-template"),
		TemplateData: map[string]interface{}{
			"first_name":     "John",
			"invoice_amount": "49.99",
		},
		CC: []string{"finance@yourdomain.com"},
		Attachments: []sendsculpt.Attachment{
			{
				Filename: "invoice.pdf",
				FilePath: "/path/to/invoice.pdf", // Auto-converted to Base64
				MimeType: "application/pdf",
			},
		},
	}

	res, err := client.SendEmail(req)
	if err != nil {
		log.Fatalf("Error: %v", err)
	}

	fmt.Println("Message ID:", res.MessageID)
}
```

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