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

# Ruby

> SendSculpt Ruby official client.

<Note>Requires Ruby 2.6+</Note>

## Installation

Add this line to your application's Gemfile:

```ruby theme={null}
gem 'sendsculpt-sdk'
```

And then execute:

```bash theme={null}
bundle install
```

Or install it directly:

```bash theme={null}
gem install sendsculpt-sdk
```

## Quick Start

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

```ruby theme={null}
require 'sendsculpt'

client = Sendsculpt::Client.new('your-api-key')

begin
  response = client.send_email(
    to: ['recipient@example.com'],
    subject: 'Welcome to SendSculpt!',
    from_email: 'noreply@yourdomain.com',
    body_html: '<p>Hello! This is a test email from the SendSculpt Ruby SDK.</p>'
  )
  puts "Success: #{response}"
rescue => e
  puts "Failed to send: #{e.message}"
end
```

## Advanced Usage

The Ruby SDK provides a convenience layer for file attachments. Providing a `file_path` will automatically base64-encode it for upload.

```ruby theme={null}
require 'sendsculpt'

client = Sendsculpt::Client.new('your-api-key')

begin
  response = client.send_email(
    to: ['john@doe.com'],
    subject: 'Your Monthly Invoice',
    from_email: 'billing@yourdomain.com',
    template_id: 'your-template-uuid',
    template_data: {
      first_name: 'John',
      invoice_amount: '49.99'
    },
    cc: ['finance@yourdomain.com'],
    attachments: [
      {
        filename: 'invoice.pdf',
        file_path: '/path/to/local/invoice.pdf', # Auto-converted to Base64!
        mime_type: 'application/pdf'
      }
    ]
  )
  puts "Email queued successfully. Message ID: #{response['message_id']}"
rescue => e
  puts e.message
end
```

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