Ruby: Parse DLR from an Android SMS Gateway API

Featured illustration for Ruby: Parse DLR from an Android SMS Gateway API

Parse delivery reports from an Android SMS Gateway API in Ruby: state machines, idempotent updates, Bangladesh geo notes.

Written by the SMS Gateway team for operators who run phones and airtime themselves — not for theoretical cloud SMS demos.

InformationAndroid SMS GatewayAPIDevelopers
Article
Published
November 12, 2024
Updated
December 19, 2024
Reading time
17 minute read

Key Takeaways

  • Ruby parse DLR on an Android SMS gateway API means mapping message.status from GET /messages/{id} or webhooks — not treating HTTP accept as delivered.
  • Use Net::HTTP or Faraday over HTTPS/JSON. This is not a packaged Ruby SMS SDK or gem product.
  • Deduplicate webhook event ids before updating rows. Confirm live enums in Developer Center.
  • You bring phone and operator airtime. Failed DLR does not cash out carrier credit.
  • Free/Developer pause at the platform SMS allowance. We meter devices + send volume.

Ruby parse DLR on an android sms gateway api is mapping delivery state after the SIM transmitted — or failed to. Product: delivery reports. API corner: Android SMS Gateway API. Docs: Developer Center.

REST HTTPS/JSON only — not a Complete Ruby SDK. Devices and send volume. You fund the SIM.

Pending → Delivered (when the carrier says so)

Accepted is not delivered

Send returns a batch with Pending:

{
  "campaignId": 17,
  "accepted": 1,
  "scheduledAt": null,
  "messages": [
    {
      "id": 41822,
      "number": "+14155552671",
      "text": "Your verification code is 481920",
      "type": "sms",
      "status": "Pending",
      "campaignId": 17,
      "deviceId": 3
    }
  ]
}

If Sidekiq marks the user “notified” on HTTP 200/202, you will debug OTPs that never left the docked phone.

How to parse DLR in Ruby

  1. Persist messages[].id.
  2. GET that id or wait for webhook.
  3. Map status / deliveredAt.
  4. Do not treat DLR as login success.

GET /messages/{id}

curl -X GET "https://app.sms-gateway.app/api/v1/messages/41822" \
  -H "Authorization: Bearer $SMS_GATEWAY_API_KEY"

Confirm the GET body in docs. Match OpenAPI — do not invent properties from this sketch.

Status map

You seeMeansYour row
PendingQueued / not yet radiosent_pending
DeliveredCarrier DLR when provideddelivered
FailedRadio or SMSC gave upfailed — inspect; don’t auto-resend without a new key

Sibling: C# parse DLR. JSON: Ruby JSON.

Prefer webhooks

{
  "id": "evt_01K2F8QW3N4RXB7M",
  "type": "message.delivered",
  "createdAt": "2026-08-12T14:04:09Z",
  "apiVersion": "2026-08-12",
  "data": {
    "message": {
      "id": 41823,
      "number": "+14155552671",
      "text": "Your verification code is 481920",
      "status": "Delivered",
      "campaignId": 17,
      "deviceId": 3,
      "metadata": { "orderId": "1234" },
      "sentAt": "2026-08-12T14:04:02Z",
      "deliveredAt": "2026-08-12T14:04:09Z"
    }
  }
}

HMAC + event-id unique. Server webhook · /webhook.

Net::HTTP sketch

# Sketch only — confirm JSON shape in Developer Center
require "net/http"
require "json"
require "uri"

def get_dlr(api_key, id)
  uri = URI("#{API_DLR_URL}/#{id}")
  req = Net::HTTP::Get.new(uri)
  req["Authorization"] = "Bearer #{api_key}"
  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }
  raise "dlr_http_#{res.code}" unless res.is_a?(Net::HTTPSuccess)
  JSON.parse(res.body)
end

OTP path: OTP verification. Keep keys server-side — never in a mobile client.

DLR is not a refund

Failed after the SIM fired still cost airtime. Free: 300 SMS lifetime. We meter devices + volume; carrier fair-use remains. No “Unlimited SMS” titles for this tutorial.

Next steps

Send one staff SMS, GET the id, then fire a webhook into a Rack endpoint. Downloads.

Jump to the live product docs for this topic—not another long-form article.

FAQ

Frequently asked questions

Direct answers about android sms gateway api.

How do I parse DLR from an Android SMS gateway API in Ruby?

Persist messages[].id from send. GET /messages/{id} with Bearer auth, or handle message.delivered / message.failed webhooks. Parse JSON with the stdlib or Oj. Verify HMAC on webhooks.

Is there an official Ruby SDK?

No. Call REST HTTPS/JSON yourself. Language samples elsewhere are examples, not a gem you must install.

Should I poll forever?

No. Webhooks in production; poll as break-glass for a single support ticket.

Does a failed DLR refund SMS?

Operator airtime may already be spent. On Free and Developer, sending pauses when you use the plan SMS allowance rather than silently billing aggregator-style overage. Upgrade or request a custom allowance to continue. Free is 300 SMS lifetime.
Keep learning

Topically related guides—chosen by subject overlap, not a fixed sitewide footer.

Information
ruby android sms gateway api

Ruby Android Sms Gateway Api: In-Depth Guide

Ruby Android Sms Gateway Api: In-Depth Guide. Long-tail article focused on exact query "ruby android sms gateway api". Expand with examples, limits, FAQ, and links to hub C. Priced by devices and SMS send volume; BYO phone and operator credit. Developer Center owns live API parameters.

Feb 21, 202616 min
Read article

Browse the full Android SMS gateway knowledge base or return to how an Android SMS gateway works.

Get started

Test the gateway on your own Android phone

Install the app, pair one device, and validate your API flow before choosing a paid plan.

You supply the phone, SIM, and operator SMS credit.