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
| Field | Type | Required | Description |
|---|---|---|---|
message | String | Yes | Main notification message |
channel | String | No | Target channel name |
event | String | No | Event key for routing |
title | String | No | Short title |
tags | Array | No | Categorisation tags |
link | String | No | URL associated with the event (deeplink + CTA) |
data | Hash | No | Arbitrary key-value metadata |