Expand description
Async Rust SDK for the Infobip SMS API.
This crate wraps the latest revision of every Infobip SMS endpoint into
strongly-typed Rust structs and async methods on a single Client.
Requests and responses are JSON; XML responses are not supported.
§Quick start
use infobip_sms::{Auth, Client};
use infobip_sms::models::send::{
SmsMessage, SmsMessageContent, SmsRequest, SmsTextMessageContent, SmsToDestination,
};
// Your account base URL is shown in the Infobip portal — usually
// something like `https://xxxxx.api.infobip.com`.
let client = Client::builder()
.base_url("https://xxxxx.api.infobip.com")
.auth(Auth::api_key("YOUR_API_KEY"))
.build()?;
let request = SmsRequest {
messages: vec![SmsMessage {
sender: Some("InfoSMS".into()),
destinations: vec![SmsToDestination {
to: "41793026727".into(),
..Default::default()
}],
content: SmsMessageContent::Text(SmsTextMessageContent {
text: "Hello from Rust!".into(),
..Default::default()
}),
..Default::default()
}],
options: None,
};
let response = client.send_messages(&request).await?;
println!("Bulk ID: {:?}", response.bulk_id);§Endpoints
Only the latest version of every endpoint is exposed. Deprecated v1 and v2 send / log / report endpoints are intentionally omitted.
| Method | Path | Client method |
|---|---|---|
POST | /sms/3/messages | Client::send_messages |
POST | /sms/1/preview | Client::preview_message |
GET | /sms/3/reports | Client::get_delivery_reports |
GET | /sms/3/logs | Client::get_logs |
GET | /sms/1/inbox/reports | Client::get_inbound_messages |
GET | /sms/1/bulks | Client::get_scheduled_bulk |
PUT | /sms/1/bulks | Client::reschedule_bulk |
GET | /sms/1/bulks/status | Client::get_bulk_status |
PUT | /sms/1/bulks/status | Client::update_bulk_status |
POST | /ct/1/log/end/{messageId} | Client::end_conversion_log |
§Authentication
Every Infobip endpoint accepts four authentication schemes. Pick one that matches what your account is provisioned for:
use infobip_sms::Auth;
// `Authorization: App <key>` — recommended for service-to-service.
let _ = Auth::api_key("YOUR_API_KEY");
// HTTP Basic auth.
let _ = Auth::basic("username", "password");
// `Authorization: IBSSO <token>` — Infobip Single Sign-On.
let _ = Auth::ibsso("YOUR_IBSSO_TOKEN");
// `Authorization: Bearer <token>` — OAuth2 client credentials.
let _ = Auth::bearer("YOUR_OAUTH2_TOKEN");See Auth for details.
§Error handling
Every fallible call returns Result<T, Error>. The two main
error variants you care about are:
Error::Api— emitted by the v3 endpoints (/sms/3/*). Wraps a structuredApiErrorwitherrorCode,description,action, and a list of validation violations.Error::Exception— emitted by the legacy/sms/1/*endpoints. Wraps anApiExceptionwith amessageId/textpair.
Inspect the HTTP status via the status field on either variant. See
the error module for the full type tree.
§Models and webhooks
All wire schemas live in models. The models::webhooks module
exposes the payload shapes Infobip POSTs to your callback URLs — use
them as Deserialize targets in your webhook handlers.
§Building blocks
Client— async, cheaply cloneable wrapper around areqwest::Client.ClientBuilder— configure base URL, auth, timeout, user-agent, or supply a customreqwest::Client.Auth— authentication scheme.
§Cargo features
No optional features are exposed in this version. The default feature
set links reqwest with rustls-tls; if you need native-tls
instead, build a reqwest::Client yourself and hand it to
ClientBuilder::http_client.
§MSRV
Edition 2024. The crate tracks the latest stable Rust release.
Re-exports§
pub use client::Auth;pub use client::Client;pub use client::ClientBuilder;pub use error::ApiError;pub use error::ApiException;pub use error::Error;