Skip to main content
The Ruby SDK is the sendflit gem. It has no runtime dependencies and uses the standard library’s net/http. It requires Ruby 2.7 or later.
Looking for another language? See the SDK overview.

Install

Or add it to your Gemfile:

Create a client

The constructor takes these keyword arguments:

Send an email

send takes keyword arguments. The keys are the same as the API’s fields.
send returns the response as a Hash with string keys. The id is what you use to look up or cancel the email later. Keyword arguments you can pass: nil values are dropped before the request is sent.

Attachments

Each attachment is a Hash with filename:, content: and an optional content_type:. The SDK base64-encodes content for you.
Limits:
  • Up to 10 attachments per message.
  • Up to 10 MB per attachment. Larger files are rejected with 422.

Batch sending

batch sends up to 100 emails in one request. Pass an array of Hashes with the same keys as send.
The response has a results array in the same order as your input, and a count. An empty array raises TypeError, and more than 100 emails raises RangeError, before any request is made. See Batch sending.
The Ruby SDK doesn’t send an Idempotency-Key header yet, so a retried send can deliver twice. Check the earlier result before you retry. See Idempotency.

Manage emails

cancel_email removes an email that hasn’t been sent yet. If the email was already sent, the API returns an error, which the SDK raises as SendFlit::Error.

Domains

You can send only from a verified domain. For DNS setup, see Domains.

Suppressions

reason: is optional and defaults to "unsubscribe". See Emails.

Usage and health

Verify webhooks

SendFlit signs each webhook. The X-Sendflit-Signature header carries sha256=<hex>, an HMAC-SHA256 of the raw body. Use the class method to check it.
The comparison uses OpenSSL.secure_compare, which runs in constant time. See Webhooks for the event list.

Errors and retries

Every failed request raises SendFlit::Error: Network problems and timeouts aren’t wrapped. They raise the standard Ruby exceptions, such as Net::OpenTimeout, Net::ReadTimeout or SocketError.
Requests that fail with 429 or 5xx are retried up to max_retries times. Other 4xx responses are not retried. See Errors, retries and limits.

Method reference

Next steps