WhatsApp API for Ruby

Uses Net::HTTP from the standard library. Works in plain Ruby and Rails. There is no official SDK, just one HTTP request.

Send a message with Ruby

Ruby
require "net/http"
require "json"

uri = URI("https://quackapi.com/v1/messages/chat")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json", "x-api-key" => ENV.fetch("QUACKAPI_KEY"))
request.body = {
  deviceId: 1,
  to: '923001234567',
  body: 'Hello from QuackAPI',
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 15) { |http| http.request(request) }
puts "#{response.code} #{response.body}"

Before you run it

  • Connect a device and use its numeric id as deviceId.
  • Set QUACKAPI_KEY to your wa_ key.
  • Run this on a server. Never ship the key to a browser or app.

Ruby tips

  • In Rails, send from an Active Job so a slow response never holds up a web request.
  • Rescue Net::OpenTimeout and Net::ReadTimeout and retry once or twice.

Handling errors

Non-2xx responses carry a JSON message. See the errors page for what each code means and which to retry.

Related

Last reviewed 2026-11-09. QuackAPI is an unofficial linked-device service. Acceptable use