Skip to main content

Global configuration

WhatsrbCloud.configure do |c|
  c.api_key  = ENV["WHATSRB_API_KEY"]
  c.base_url = "https://api.whatsrb.com"  # default
  c.timeout  = 30                          # seconds, default
end

Default client

After configuring globally, access a shared client singleton:
WhatsrbCloud.configure do |c|
  c.api_key = ENV["WHATSRB_API_KEY"]
end

# Uses the global configuration — no need to instantiate
WhatsrbCloud.client.agents.list
WhatsrbCloud.client.webhooks.list
The singleton is lazy-loaded and reset when you call WhatsrbCloud.reset_configuration!.

Per-client configuration

client = WhatsrbCloud::Client.new(
  api_key:  "wrb_live_xxx",
  base_url: "https://api.whatsrb.com",
  timeout:  30
)
Per-client options override the global configuration.

Rails initializer

Create config/initializers/whatsrb.rb:
WhatsrbCloud.configure do |c|
  c.api_key = Rails.application.credentials.whatsrb_api_key
end

Available options

OptionDefaultDescription
api_keyYour WhatsRB API key (required)
base_urlhttps://api.whatsrb.comAPI base URL
timeout30Request timeout in seconds