Ruby SDK
RubyGems: coffeemail v0.1.0Complete reference for the official coffeemail gem for Ruby 3.3+. No runtime dependencies, immutable models, safe data, error results, RBS types and webhook verification.
Looking for the Node.js or TypeScript documentation? See the official @coffeemail/node package reference.
Installation
rubygems.org/gems/coffeemail ↗Client Initialization
Without api_key:, the key is read from the COFFEEMAIL_API_KEY environment variable. The client is immutable and can be shared across threads.
CoffeeMail::Client.new(api_key: nil, locale: "pt-BR", timeout: 10, retry_policy: nil, transport: nil)Safe Results and Error Handling
Safe Pattern data, errorEvery operation returns a CoffeeMail::Response with data or error. Destructure with data, error = ..., use pattern matching or call unwrap! to raise the typed error.
Cryptographic Webhook Verification
CoffeeMail::Webhook.from_rack validates the x-webhook-signature header (HMAC SHA-256 of timestamp, idempotency key and raw body) in constant time and rejects deliveries outside the 5-minute window.
Methods Catalog
Reference for the most used operations of the official Ruby client.
Emails
client.emails.send(from:, to:, subject: nil, html: nil, text: nil, idempotency_key: nil, sandbox: false, **) -> Response[SendEmailResult]client.emails.send_batch(items) -> Response[Array[BatchSendItem]]client.emails.get(id) -> Response[EmailDetail]client.emails.list(status: nil, after: nil, limit: nil, **) -> Response[EmailList]Domains
client.domains.create(name:) -> Response[CreatedDomain]client.domains.verify(id) -> Response[DomainVerification]Templates
client.templates.create(name:, html:, alias: nil, subject: nil, format: nil, **) -> Response[TemplateDetail]client.templates.preview_by_id(id, variables: nil) -> Response[RenderedTemplate]Audiences and Contacts
client.audiences.contacts.create(audience_id, email:, first_name: nil, last_name: nil, metadata: nil) -> Response[Contact]Broadcasts
client.broadcasts.create(audience_id:, from_email:, template_id: nil, subject: nil, **) -> Response[BroadcastDetail]Suppressions
client.suppressions.create(email:, reason: nil, expires_at: nil) -> Response[SuppressionDetail]Webhooks
client.webhooks.create(url:, events:, description: nil) -> Response[WebhookDetail]CoffeeMail::Webhook.from_rack(request, secret:, tolerance: 300) -> Response[Webhook::Event]Metrics
client.stats.get(start_date: nil, end_date: nil, granularity: nil, **) -> Response[Stats]