Skip to main content

Ruby SDK

The Orbit Ruby SDK wraps the platform’s core API resources — messaging (SMS, WhatsApp, email), voice, contacts, campaigns, verify (OTP), and webhook signature verification — with typed methods. It requires Ruby 2.7+.
Pre-publish — source-only. This SDK is not yet on RubyGems — the Gemfile line below describes the future registry shape. Until first publish, vendor the source from the monorepo (packages/sdk-ruby/) or call the REST API directly. See Ruby: core-scope, not full parity on the SDK index for exactly what is and isn’t wrapped, and the low-level client.request(method, path, **opts) escape hatch for uncovered routes (worked example below).

Installation

The gem is not on RubyGems yet — gem install orbit_sdk currently 404s. Until first publish, vendor the source from the monorepo in your Gemfile:
then bundle install. Requires Ruby 2.7+. Once the gem ships on RubyGems, gem "orbit_sdk", "~> 0.2" / gem install orbit_sdk become the documented install here.

Client initialization

Or read the key from an environment variable (ORBIT_API_KEY):
Tune timeouts and retries with the direct constructor:

Quickstart: send your first SMS

A runnable end-to-end — the key comes from ORBIT_API_KEY, never from source. Copy it into first_send.rb and run it with ruby first_send.rb:
Point ORBIT_API_KEY at a sandbox key prefixed dv_test_sk_ first — sandbox sends are simulated, free, and never reach a carrier. Swap in your live key (dv_live_sk_...) when you’re ready to send for real; the code does not change. The response shape above comes from the Messages API reference — its language tabs include this exact call.

Messaging

Voice

Outbound voice always exits through Devotel’s wholesale softswitch — the SDK submits a request to the Orbit API and never selects a carrier itself.

Verify (OTP)

The send-and-check round trip is the most common first integration on the platform — here as a complete flow. Send the code, keep the returned verification id, and check the code the user typed in against it:
A wrongly-typed or expired code reports valid: false — it never raises for a bad guess (only for transport/auth failures), so branch on the flag. The Verify API reference covers the full contract, and Starter examples ships a complete OTP sign-in starter repo (orbit-otp-nextjs).

Contacts

Campaigns

Paginate a list

List endpoints are cursor-paginated — read meta.pagination.cursor and meta.pagination.has_more off each response and pass the cursor back as a query param until has_more is false. Page through SMS messages with the escape hatch:
The full pagination model (cursor vs. offset endpoints, page-size caps, and why cursors are not bookmarkable) is in the Pagination guide.

Error handling

All Orbit-originated errors inherit from OrbitSdk::OrbitError:
Every non-GET request automatically carries an Idempotency-Key header (UUIDv4); override it per call with your own stable key (idempotency_key: "job-7a3b9d-attempt-1").

Covered route missing? Use the escape hatch

The typed clients wrap 8 core resources; the rest of the API — contact segments, event sinks, frequency caps, and everything else listed as out of scope on the SDK index — is reachable through client.request(method, path, **opts). It returns the raw JSON body as a Hash. Fetch a segment by id:
The escape hatch carries the same auth, retry, and error model as the typed clients — treat it as a first-class client, not a fallback net/http call.

Push device tokens (backend pair for the mobile SDKs)

The Android, iOS, Flutter, and React Native SDK pages hand token onboarding to a backend: POST /api/v1/push/device-tokens, authenticated with a secret key, takes the native APNs / FCM token that the Android or Swift app produces (or a Web Push subscription envelope for platform: 'web') and the user_id the device belongs to. Registration is server-side — the mobile apps ship only the publishable key. The Node SDK wraps this call as a typed method (orbit.push.tokens.register); every other backend language, Ruby included, calls it over the escape hatch:
The 201 wraps the stored row in the standard envelope — data.id is the handle you delete on sign-out:
201 Created
Re-registering an existing token is an upsert — call it on every native token rollover, the row is updated, last_seen is bumped, and the 201 returns the original id, so a stored id stays valid. On sign-out, unregister so the device stops receiving pushes; a stale stored id falls back to ?token=<raw-token>:
To exercise the flow without touching real devices, point ORBIT_API_KEY at a sandbox key (dv_test_sk_…); dashboard sessions add X-Test-Mode: true via the console’s Test/Live toggle. See Sandbox API samples. The sibling client pages carry the same flow as a six-language sample group; the call is identical here, just reached through the escape hatch this section documents.

Webhook signature verification

Runnable examples

The package’s examples/ directory holds self-contained, runnable end-to-end files (each takes ORBIT_API_KEY / ORBIT_WEBHOOK_SECRET from the environment): first SMS send, cursor pagination over GET /messages, the OTP send+check round trip, a programmable outbound call with an answer_url callback, and webhook signature verification against a signed test payload. Run any of them with ruby examples/<name>.rb.