Browse Docs

Ruby Alerts SDK

The API Alerts Ruby SDK sends alerts from your Ruby code through API Alerts. Drop it into Rails applications, Sinatra apps, Sidekiq workers, or any Ruby script that needs to notify you when something important happens. Minimal setup, fire-and-forget by default with optional response handling, and zero infrastructure.

Installation

gem 'apialerts'

Or:

gem install apialerts

Quick Start

require 'apialerts'

ApiAlerts.configure('your-api-key')
ApiAlerts.send(ApiAlerts::Event.new(message: 'Deploy complete'))

Usage

The SDK exposes a singleton (ApiAlerts) for most use cases and an instance-based client (ApiAlerts::Client) when you need multiple clients.

Fire and forget

ApiAlerts.configure('your-api-key')

# Never raises. Safe to call anywhere.
ApiAlerts.send(ApiAlerts::Event.new(message: 'Deploy complete'))

Wait for response

send_async returns a SendResult and never raises. Check result.success? to determine whether delivery succeeded.

result = ApiAlerts.send_async(ApiAlerts::Event.new(
  message: 'New user signed up',
  channel: 'revenue',
  event:   'user.signup',
  title:   'New Signup',
  tags:    ['growth', 'organic'],
  link:    'https://dashboard.example.com/users/123',
  data:    { plan: 'pro', source: 'organic' }
))

if result.success?
  puts "Sent to #{result.workspace} (#{result.channel})"
else
  puts "Error: #{result.error}"
end

Multiple workspaces

Pass an optional api_key: to override the configured key for a single call.

ApiAlerts.send(event, api_key: 'other-api-key')

result = ApiAlerts.send_async(event, api_key: 'other-api-key')

Instance client

Construct ApiAlerts::Client directly when you need several clients (for example one per workspace) or prefer dependency injection over the global singleton. It exposes the same send / send_async methods.

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

client.send(ApiAlerts::Event.new(message: 'Deploy complete'))

result = client.send_async(ApiAlerts::Event.new(message: 'Deploy complete'))

Event Fields

FieldTypeRequiredDescription
messageStringYesMain notification message
channelStringNoTarget channel name
eventStringNoEvent key for routing
titleStringNoShort title
tagsArrayNoCategorisation tags
linkStringNoURL associated with the event (deeplink + CTA)
dataHashNoArbitrary key-value metadata