Expand description
Async Rust SDK for the OpenSMS prepaid SMS API.
Send SMS and OTPs, run batches, look up numbers, manage contacts,
templates, webhooks, numbers and sender IDs, and read the wallet and
analytics. Built on reqwest and serde, with one transport layer that
owns bearer auth, Idempotency-Keys, retries on 429/5xx/network errors
(honouring Retry-After), and error mapping to OpensmsError.
§Quickstart
use opensms::{Client, SendMessage};
#[tokio::main]
async fn main() -> Result<(), opensms::OpensmsError> {
let client = Client::new(std::env::var("OPENSMS_API_KEY").unwrap())?;
let message = client
.messages()
.send(&SendMessage::new("+254700000012", "Your order has shipped"))
.await?;
println!("{} {:?}", message.id, message.status);
Ok(())
}Re-exports§
pub use webhook::construct_event;pub use webhook::verify_signature;pub use webhook::VerifyOptions;
Modules§
- webhook
- Webhook signature verification.
Structs§
- Analytics
- Accessed as
client.analytics(). - Analytics
Overview - Headline analytics.
- Analytics
Point - One time-series bucket.
- Analytics
Query - Query shared by the analytics methods.
range(Nd) cannot be combined withfrom/to. - Analytics
Row - One row of a dimension breakdown (
by_country,by_carrier,by_sender_id). - Attempt
- One delivery attempt of a message.
- Batch
- A message batch.
- Batch
Item Input - One row of a batch create request.
- Batch
Report - Validation report of a batch.
- Batch
Report Row - One row of a
BatchReport. - Batch
Stop Result - Result of
batches.stop. - Batches
- Accessed as
client.batches(). - Carrier
- A carrier in a country.
- Check
Sender Id - Query for
sender_ids.check. - Client
- OpenSMS API client. Cheap to clone; clones share one connection pool.
- Client
Builder - Builder for
Client. Construct withClient::builder. - Compliance
- Accessed as
client.compliance(). - Contact
- A contact.
- Contact
Group - A contact group.
- Contact
Groups - Accessed as
client.contact_groups(). - Contacts
- Accessed as
client.contacts(). - Content
Rule - A workspace-visible content rule.
- Countries
- Accessed as
client.countries(). - Country
- A destination country in the public catalog.
- Country
Content Rule - A content rule inside
CountryRules. - Country
Rules - Compliance rules for a country.
- Create
Batch - Body of
batches.create. - Create
Contact - Body of
contacts.create. - Create
Contact Group - Body of
contact_groups.create. - Create
Lookup - Body of
lookups.create. - Create
Sender Id - Body of
sender_ids.create. - Create
Sender IdDraft - Body of
sender_ids.create_draft. - Create
Suppression - Body of
suppressions.createand one row ofsuppressions.import. - Create
Template - Body of
templates.create. - Create
Topup - Body of
wallet.create_topup. - Create
Webhook - Body of
webhooks.create. - Http
Request - One HTTP request as handed to a
Transport. - Http
Response - One HTTP response as returned by a
Transport. - Inbound
- Accessed as
client.inbound(). - Inbound
Message - An inbound SMS.
- Ledger
Entry - A wallet ledger entry.
- Ledger
Params - Query for
wallet.ledger(pages bybefore, not by cursor). - List
Batch Items - Query for
batches.list_items. - List
Messages - Query for
messages.list. - List
Params limit+cursorfor cursor-paginated lists.- Lookup
- A number lookup.
- Lookups
- Accessed as
client.lookups(). - Message
- An SMS message. Also used for batch items, which carry fewer fields.
- Messages
- Accessed as
client.messages(). - Money
- An
{ amount, currency }money value. - Number
- A virtual number.
- Number
Query - Query for
numbers.availableand body ofnumbers.assign. - Number
Rule - An inbound routing rule on a number.
- Number
Rule Input - Body of
numbers.create_ruleandnumbers.update_rule. - Numbers
- Accessed as
client.numbers(). - Opensms
Error - Returned for every non-2xx response, for transport failures that survive all retries, for invalid arguments, and for webhook signature failures.
- Otp
- Accessed as
client.otp(). - OtpSend
Result - Result of
otp.send. - OtpVerify
Result - Result of
otp.verify. - Page
- A cursor page:
{ items, next_cursor }. - Paginator
- Lazily walks every page of a cursor list. Create with
crate::Client::paginateorpaginate. - Price
Entry - One price-list row.
- Price
List - A workspace price list.
- Pricing
- Accessed as
client.pricing(). - Pricing
Params - Query for
pricing.get. - Quiet
Hours - A quiet-hours window.
- Quote
Sender Id - Query for
sender_ids.quote. - Replay
Delivery - Body of
webhooks.replay_delivery. - Reply
Inbound - Body of
inbound.reply. - Request
Options - Per-call options for methods that send an
Idempotency-Key. - Reqwest
Transport - The default
Transport, backed byreqwest. - Route
- A public routable route in a country.
- Sandbox
- Accessed as
client.sandbox(). - Sandbox
Message - A sandbox message with its rendered text (including OTP codes).
- Send
Message - Body of
messages.send. - SendOtp
- Body of
otp.send. - Send
ToGroup - Body of
contact_groups.send: settextortemplate_id. - Sender
Document - A sender registration document (metadata only).
- Sender
Id - A sender ID.
- Sender
IdCheck - Result of
sender_ids.check. - Sender
IdDraft - A sender ID application draft.
- Sender
IdQuote - Result of
sender_ids.quote. - Sender
IdQuote Entry - One fee line of a
SenderIdQuote. - Sender
Ids - Accessed as
client.sender_ids(). - Status
Result - A
{ status }acknowledgement (webhook test and replay). - Suppression
- A suppressed destination.
- Suppression
Import Result - Result of
suppressions.import. - Suppressions
- Accessed as
client.suppressions(). - Template
- A message template.
- Templates
- Accessed as
client.templates(). - Tokio
Sleeper - The default
Sleeper, backed bytokio::time::sleep. - Topup
- An initialized top-up.
- Update
Contact - Body of
contacts.update(PATCH; unset fields are kept). - Update
Contact Group - Body of
contact_groups.update. - Update
Sender Id - Body of
sender_ids.update(amend a rejected sender ID). - Update
Sender IdDraft - Body of
sender_ids.update_draft;versionmust be the current one. - Update
Template - Body of
templates.update. - Update
Webhook - Body of
webhooks.update: a full replacement, every field required. - Verify
Otp - Body of
otp.verify. - Wallet
- Accessed as
client.wallet(). - Wallet
Balance - A wallet balance.
- Webhook
Delivery - One webhook delivery.
- Webhook
Endpoint - A webhook endpoint.
- Webhook
Event - A verified webhook event envelope.
- Webhooks
- Accessed as
client.webhooks().
Enums§
- Error
Kind - What kind of failure an
OpensmsErrordescribes.
Constants§
- USER_
AGENT - The
User-Agentsent on every request.
Traits§
- Sleeper
- Waits between retry attempts. Tests inject one that returns immediately.
- Transport
- Sends one HTTP request. Return
Errfor network failures and timeouts (anything with no HTTP response); every HTTP status is anOk.
Functions§
- paginate
- Build a
Paginatorfrom a closure that fetches one page given the cursor (Nonefor the first page). - rfc3339
- Format a time as an RFC 3339 UTC string with second precision, for example
2026-09-24T12:00:00Z. Use it forscheduled_atand analyticsfrom/to. - uuid_v4
- A random (version 4) UUID, 36 characters.