SDK
SMS SDK
Official WRNexus SDKs for SMS — install, configure from the environment, and call send / status / senders / templates / balance with typed responses and structured errors in JavaScript, Python, Go, Java, and Rust.
The official WRNexus SDKs wrap the public API with typed methods, environment-based configuration, and a structured error hierarchy. They are available for JavaScript/TypeScript, Python, Go, Java, and Rust, and share one cross-language design — the same methods, parameters, and response fields in every language.
One client, many products. Every product is a lazily-created namespace over the client’s single shared transport (base URL + auth header + timeout + JSON codec), so new products attach without breaking changes. SMS is
client.sms(below);client.emailandclient.whatsappare documented on the Email SDK and WhatsApp SDK pages.
Configuration (environment variables)
Every SDK reads its configuration from the environment by default, so any module can construct a client without threading config around. Explicit constructor options always override the environment.
| Setting | Env var | Default |
|---|---|---|
| API key | WRNEXUS_API_KEY |
(required) |
| Base URL | WRNEXUS_API_BASE_URL |
https://app.wrnexus.com |
| Timeout | WRNEXUS_TIMEOUT_MS |
30000 |
export WRNEXUS_API_KEY="wrn_live_xxx"
Create your key under Developer → API Keys in the Account app — see Authentication.
SMS methods (all languages)
client.sms exposes the same surface everywhere:
| Method | Required scope | Returns |
|---|---|---|
send(...) |
sms:send |
Queued message: messageId, status, segments, creditsCost, creditsRemaining, … |
status(id) |
sms:read |
Delivery status: status, lastError, sentAt, … |
senders() |
sms:read |
The organization’s registered senders. |
templates() |
sms:read |
Templates and their required variables. |
balance() |
sms:read |
Remaining SMS credits for the workspace. |
client.me() returns the identity the key resolves to (key id, organization,
scopes) — handy to verify a key works.
send parameters — names are shown in their JS/TS form; Python uses
snake_case (and from_ for from):
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
to |
string (E.164) |
Yes | — | Destination number, e.g. +919812345678. |
from |
string |
Yes | — | Registered sender id or header (see senders()). |
template |
string |
Cond.* | — | Template id or name. templateId is accepted as an alias. |
message |
string |
Cond.* | — | Convenience body that fills a single-placeholder template. |
variables |
object (str→str) |
No | {} |
Token → value map used to render a multi-placeholder template. |
flash |
boolean |
No | false |
Send as a class-0 flash SMS (shown on screen, not stored). |
scheduledAt |
string (RFC 3339) |
No | null |
Future send time. Omit/null sends immediately. |
* Provide either template (+ variables) or message. A bare
single-placeholder template can be filled with message.
Other methods: status(id) takes the messageId string returned by send;
senders(), templates(), balance(), and me() take no parameters.
JavaScript / TypeScript
Install (Node 18+, ESM + CommonJS, zero runtime deps):
npm install @wrnexus/sdk
Initialize:
import { WrNexusClient } from '@wrnexus/sdk';
// Reads WRNEXUS_API_KEY from the environment.
const client = new WrNexusClient();
// Or configure explicitly:
const explicit = new WrNexusClient({
apiKey: 'wrn_live_xxx',
baseUrl: 'https://app.wrnexus.com',
timeoutMs: 15_000,
});
Send and read:
const res = await client.sms.send({
to: '+919812345678',
from: 'ACMEIN',
template: 'OTP verify',
variables: { code: '4821' },
flash: false,
});
console.log(res.messageId, res.status, res.creditsRemaining);
const status = await client.sms.status(res.messageId);
const senders = await client.sms.senders();
const templates = await client.sms.templates();
const balance = await client.sms.balance();
const identity = await client.me();
Error handling — every non-2xx rejects with a typed error:
import {
WrNexusAuthError, // 401 / 403 — fix the key, scope, or IP
WrNexusServerError, // 5xx — retryable; .isBadGateway for the 502 case
WrNexusApiError, // other 4xx — .statusCode, .code, .message
WrNexusTransportError, // no HTTP response (DNS, timeout) — retryable
} from '@wrnexus/sdk';
try {
await client.sms.send({ to: '+919812345678', message: '4821', from: 'ACMEIN' });
} catch (err) {
if (err instanceof WrNexusApiError) console.error(err.statusCode, err.code, err.message);
}
Python
Install (Python 3.8+, uses httpx, ships py.typed):
pip install wrnexus
Initialize:
from wrnexus import WrNexusClient
client = WrNexusClient() # reads WRNEXUS_API_KEY
explicit = WrNexusClient(
api_key="wrn_live_xxx",
base_url="https://app.wrnexus.com",
timeout=15.0, # seconds
)
Send and read (from_ carries a trailing underscore — from is a Python
keyword):
with WrNexusClient() as client: # closes the HTTP pool on exit
res = client.sms.send(
"+919812345678", # to
from_="ACMEIN",
template="OTP verify",
variables={"code": "4821"},
)
print(res.message_id, res.status, res.credits_remaining)
status = client.sms.status(res.message_id)
senders = client.sms.senders()
templates = client.sms.templates()
balance = client.sms.balance()
identity = client.me()
Error handling:
from wrnexus import (
WrNexusAuthError, WrNexusServerError, WrNexusApiError, WrNexusTransportError,
)
try:
client.sms.send("+919812345678", "4821", from_="ACMEIN")
except WrNexusApiError as err:
print(err.status_code, err.code, err.message)
A missing API key raises WrNexusConfigError at construction, before any
request is made.
Go
Install:
go get github.com/wrnexus/wrnexus-go
Initialize and send:
import (
"context"
"time"
wrnexus "github.com/wrnexus/wrnexus-go"
)
client, err := wrnexus.New( // or wrnexus.New() to read the env
wrnexus.WithAPIKey("wrn_live_xxx"),
wrnexus.WithBaseURL("https://app.wrnexus.com"),
wrnexus.WithTimeout(15*time.Second),
)
if err != nil { /* handle config error */ }
ctx := context.Background()
res, err := client.SMS().Send(ctx, wrnexus.NewSendSMSRequest("+919812345678").
WithFrom("ACMEIN").
WithTemplate("OTP verify").
WithVariables(map[string]any{"code": "4821"}))
if err != nil { /* see errors below */ }
status, _ := client.SMS().Status(ctx, res.MessageID)
senders, _ := client.SMS().Senders(ctx)
templates,_ := client.SMS().Templates(ctx)
balance, _ := client.SMS().Balance(ctx)
me, _ := client.Me(ctx)
Errors: *ConfigError, *APIError (with StatusCode, Code, Message,
IsRetryable(), IsBadGateway()) and its specializations *AuthError,
*ValidationError, *ServerError, plus *TransportError and *DecodeError.
The package helper wrnexus.IsRetryable(err) reports whether a retry is worth
attempting.
Java
Install (Maven):
<dependency>
<groupId>com.wrnexus</groupId>
<artifactId>wrnexus-sdk</artifactId>
<version>1.0.0</version>
</dependency>
Initialize and send:
import com.wrnexus.sdk.WrNexusClient;
import com.wrnexus.sdk.model.*;
WrNexusClient client = WrNexusClient.builder() // or new WrNexusClient() for env config
.apiKey("wrn_live_xxx")
.baseUrl("https://app.wrnexus.com")
.timeoutMs(15_000)
.build();
SendSmsResponse res = client.sms().send(
new SendSmsRequest()
.to("+919812345678")
.from("ACMEIN")
.template("OTP verify")
.variables(Map.of("code", "4821")));
MessageStatus status = client.sms().status(res.messageId);
List<Sender> senders = client.sms().senders();
List<Template> templates = client.sms().templates();
Balance balance = client.sms().balance();
Exceptions: WrNexusException (base), WrNexusApiException (with
getStatusCode(), getCode(), isClientError(), isServerError()),
WrNexusAuthException (401/403), WrNexusServerException (5xx), and
WrNexusTransportException (no HTTP response).
Rust
Install:
[dependencies]
wrnexus = "1"
tokio = { version = "1", features = ["full"] }
Initialize and send:
use wrnexus::{WrNexusClient, sms::SendSmsRequest};
use std::time::Duration;
let client = WrNexusClient::builder() // or WrNexusClient::from_env()?
.api_key("wrn_live_xxx")
.base_url("https://app.wrnexus.com")
.timeout(Duration::from_secs(15))
.build()?;
let req = SendSmsRequest::new("+919812345678")
.from("ACMEIN")
.template("OTP verify")
.variable("code", "4821");
let res = client.sms().send(&req).await?;
println!("{} {} {}", res.message_id, res.status, res.credits_remaining);
let status = client.sms().status(&res.message_id).await?;
let senders = client.sms().senders().await?;
let balance = client.sms().balance().await?;
let identity = client.me().await?;
Errors: all methods return Result<_, WrNexusError>. WrNexusError is an
enum with Config, Auth, Validation, Server, Transport, and Decode
variants and the helpers status(), code(), is_bad_gateway(), and
is_retryable().
See also
- SMS API — the raw HTTP endpoints these methods call.
- Authentication — create and secure an API key.
- SMS Webhooks — receive delivery events.