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

# Ruby SDK Quickstart

> Learn how to configure and send your first email with SendPost Ruby SDK

## Prerequisites

To get the most out of this guide, you'll need to:

* [**Create a SendPost Account**](https://app.sendpost.io/register)
* [**Install Ruby 2.7+**](https://www.ruby-lang.org/en/downloads/)
* A **Sub-Account API Key** from your SendPost dashboard

<Info>
  You can find your API keys in your [SendPost
  Dashboard](https://app.sendpost.io). Make sure to use your Sub-Account API Key
  for sending emails.
</Info>

## 1. Install

```shellscript shell theme={null}
gem install sendpost_ruby_sdk
```

## 2. Getting Started

```ruby Ruby theme={null}
require 'sendpost_ruby_sdk'

# Configure API key
config = Sendpost::Configuration.new
config.host = 'https://api.sendpost.io/api/v1'
config.api_key['X-SubAccount-ApiKey'] = 'your_sub_account_api_key'

# Create API client
api_client = Sendpost::ApiClient.new(config)
email_api = Sendpost::EmailApi.new(api_client)

# Create email message
email_message = Sendpost::EmailMessageObject.new

from = Sendpost::EmailMessageFrom.new
from.email = 'richard@piedpiper.com'
email_message.from = from

to = Sendpost::EmailMessageToInner.new
to.email = 'gavin@hooli.com'
email_message.to = [to]

email_message.subject = 'Hello World'
email_message.html_body = '<strong>it works!</strong>'

begin
  result = email_api.send_email(email_message)
  puts "Email sent! Message ID: #{result[0].message_id}"
rescue Sendpost::ApiError => e
  puts "Exception when calling EmailApi->send_email: #{e}"
end
```

<Warning>
  Make sure your sender email domain is verified in your SendPost account before
  sending emails.
</Warning>

## 3. Next Steps

Explore more examples and use cases:

<Columns cols={3}>
  <Card title="Ruby SDK" icon="gem" href="https://rubygems.org/gems/sendpost_ruby_sdk">
    View the official SDK package on RubyGems
  </Card>

  <Card title="SDK Examples" icon="github" href="https://github.com/sendpost/sendpost-examples-ruby">
    Comprehensive email sending examples
  </Card>

  <Card title="ESP Workflow Example" icon="diagram-project" href="https://github.com/sendpost/ruby-esp-example">
    Full-featured example app with comprehensive ESP workflow
  </Card>
</Columns>
