Skip to main content

Go SDK

The Orbit Go 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 Go 1.22+ and is safe for concurrent use across goroutines.
Pre-publish — source-only. This SDK is not yet mirrored to the public Go module repository — go get github.com/devotel/orbit-go returns 404 today. Until first publish, vendor the source from the monorepo (packages/sdk-go/) or call the REST API directly. See Go: core-scope, not full parity on the SDK index for exactly what is and isn’t wrapped, and the low-level client.Request(ctx, method, path, ...) escape hatch for uncovered routes (worked example below).

Installation

Client initialization

The client reads the key straight from your environment — there is no from_env helper in Go; use os.Getenv:
Tune the transport with functional options:

Quickstart: send your first SMS

A runnable end-to-end — the key comes from ORBIT_API_KEY, never from source. Copy it into main.go and run it with go run .:
Set ORBIT_API_KEY to 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

Sending is only the first half — fetch a message by id to read its delivery state (queued → sent → delivered), which is what a status poller or a support lookup does:
client.Messages() also exposes SendWhatsApp and SendEmail; Get (above) fetches a message by id.

Voice

A call’s full lifecycle fits in one flow: place it, poll its status, then hang up. Get returns the same call record Create did — read Status off it as it moves (queued → ringing → in-progress → completed):
List past calls with direction/status filters and cursor pagination:
All outbound calls route through the Orbit API; the SDK never selects a carrier.

Second example: verify OTP

The send-and-check round trip is the most common first integration on the platform. Two calls — the key is still just ORBIT_API_KEY passed to orbit.NewClient:
A wrongly-typed or expired code reports check.Data.Valid == false — it never errors 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 includes a complete OTP sign-in starter repo (orbit-otp-nextjs).

Verify (OTP)

Two follow-up operations round out the flow — Resend re-dispatches the code for a still-pending verification (same verification id), and GetDetail returns the full verification record (the same payload the dashboard verification drawer renders):

Contacts

The rest of the contact lifecycle reads off the id Create returned — fetch it, patch it (pointer fields are omitted from the request when nil), and delete it:

Campaigns

Rename before the send fires, or list every campaign in the organization:
client.Campaigns() also exposes Delete — client.Campaigns().Delete(ctx, id) permanently removes a campaign by id (returns no body).

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 parameter 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 are *orbit.Error. Inspect them with the helper predicates:
Every non-GET request automatically carries an Idempotency-Key header (UUID v4); override it per call via orbit.SendSMSInput{ ..., IdempotencyKey: "job-7a3b9d-attempt-1" } when retrying from your own queue.

Covered route missing? Use the escape hatch

The typed resources 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(ctx, method, path, ...). It unmarshals the raw JSON body into whatever out you pass (a map[string]any when you have no typed struct). Fetch a segment by id:
The escape hatch carries the same auth, retry, and error model as the typed resources — treat it as a first-class client, not a fallback http.Client.

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 go run ./examples/<name>.go. The same shapes are also walked task-by-task in the API recipes cookbook.