HookBridge Ruby SDK
Official Ruby SDK for HookBridge. Send webhooks with guaranteed delivery, automatic retries, and inbound/outbound observability.
Installation
Add the gem to your Gemfile:
gem "hookbridge"
Then install dependencies:
bundle install
Quick Start
require "hookbridge"
client = HookBridge.new(api_key: "hb_live_xxxxxxxxxxxxxxxxxxxx")
endpoint = client.create_endpoint(
url: "https://customer.app/webhooks",
description: "Customer production webhook"
)
result = client.send(
endpoint_id: endpoint.id,
payload: { event: "order.created" }
)
puts result.
Outbound Endpoints
endpoint = client.create_endpoint(
url: "https://customer.app/webhooks",
description: "Main production webhook",
rate_limit_rps: 10,
burst: 20
)
details = client.get_endpoint(endpoint.id)
list = client.list_endpoints(limit: 50)
rotated = client.rotate_endpoint_secret(endpoint.id)
client.delete_endpoint(endpoint.id)
Sending and Observability
result = client.send(
endpoint_id: endpoint.id,
payload: { event: "user.created", user_id: "usr_123" },
idempotency_key: "user-123-created"
)
= client.(result.)
logs = client.get_logs(limit: 100)
metrics = client.get_metrics
timeseries = client.get_timeseries_metrics(endpoint_id: endpoint.id)
client.replay(.id)
client.(status: "failed_permanent", endpoint_id: endpoint.id, limit: 50)
Inbound Webhooks
inbound = client.create_inbound_endpoint(
url: "https://myapp.com/webhooks/inbound",
name: "Stripe inbound",
description: "Receives Stripe events through HookBridge",
verify_static_token: true,
token_header_name: "X-Webhook-Token",
token_value: "my-shared-secret",
signing_enabled: true,
idempotency_header_names: ["X-Idempotency-Key"],
ingest_response_code: 202
)
puts inbound.ingest_url # Save this
puts inbound.secret_token # Only shown once
details = client.get_inbound_endpoint(inbound.id)
client.pause_inbound_endpoint(inbound.id)
client.resume_inbound_endpoint(inbound.id)
client.update_inbound_endpoint(
inbound.id,
verify_hmac: true,
hmac_header_name: "X-Signature",
hmac_secret: "whsec_inbound_secret"
)
Inbound Observability
inbound_endpoints = client.list_inbound_endpoints(limit: 50)
inbound_logs = client.get_inbound_logs(inbound_endpoint_id: inbound.id, limit: 50)
inbound_metrics = client.get_inbound_metrics(inbound_endpoint_id: inbound.id)
inbound_timeseries = client.get_inbound_timeseries_metrics(inbound_endpoint_id: inbound.id)
rejections = client.list_inbound_rejections(inbound_endpoint_id: inbound.id, limit: 25)
Billing and Exports
subscription = client.get_subscription
usage = client.get_usage_history(limit: 12, offset: 0)
invoices = client.get_invoices(limit: 12)
export = client.create_export(
start_time: Time.now.utc - 86_400,
end_time: Time.now.utc,
endpoint_id: endpoint.id
)
download_url = client.download_export(export.id)