One endpoint. Clean JSON. Under 10-second delivery to NTC, Ncell & SmartCell. SDKs for PHP, Python, Node.js, and Java.
// Send SMS — Node.js (fetch) const res = await fetch( 'https://app.bharosasms.com/api/v1/sms/send/', { method: 'POST', headers: { 'X-API-KEY': process.env.BHAROSA_API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ to: ['98XXXXXXXX'], text: 'Your OTP is 482910', sender_id: { NT: 'MYAPP', Ncell: 'MYAPP' }, message_type: 'plain' }) } );
{ "message": "SMS processed.",
"batch_id": "sbat_8f3a1b",
"cost": 1.5, "pages": 1,
"failed_numbers": [] }
There is a single endpoint for sending SMS. All requests use POST.
Every request must include your secret API key in the X-API-KEY header.
process.env.BHAROSA_API_KEY / os.environ["BHAROSA_API_KEY"] / $_ENV['BHAROSA_API_KEY']. Never commit it to Git or expose it client-side.
Paste this into your terminal, replace YOUR_API_KEY and YourSenderID, and run it. You'll get a 201 Created back.
# Quick start curl -X POST https://app.bharosasms.com/api/v1/sms/send/ \ -H "X-API-KEY: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "to": ["98XXXXXXXX"], "text": "Hello from Bharosa SMS!", "sender_id": { "NT": "YourSenderID", "Ncell": "YourSenderID" }, "message_type": "plain" }'
Send JSON in the request body with Content-Type: application/json. All fields except scheduled_at are required.
98XXXXXXXX) or international (+97798XXXXXXXX). Up to 50,000 per request.unicode for Nepali / Devanagari text.YYYY-MM-DD HH:MM:SS · Example: 2026-04-20 09:00:00A successful send returns 201 Created with this JSON body.
| Field | Type | Description |
|---|---|---|
| message | string | Human-readable operation status. |
| batch_id | ShortID | Unique ID for this batch. Use for tracking and support. |
| cost | float | Total credits deducted from your balance. |
| pages | integer | SMS units per message. Longer messages use more pages. |
| failed_numbers | array | Partial failures — each item has number and reason. Empty on full success. |
The API uses standard HTTP codes. Errors return JSON with an error or detail field.
{
"message": "SMS processed successfully.",
"batch_id": "sbat_8f3a1b",
"cost": 1.5,
"pages": 1,
"failed_numbers": [
{"number": "12345", "reason": "Unknown operator"}
]
}{ "error": "Insufficient balance." }{ "error": "Invalid date format for
'scheduled_at'. Please use
'YYYY-MM-DD HH:MM:SS'." }{ "error": "Service temporarily
unavailable. Please contact
support." }{ "detail": "Invalid or inactive API key." }Production-ready snippets in every major language. Each includes a plain send, a scheduled send, and a Nepali unicode example.
# ── Plain send ──────────────────────────────────────── curl -X POST https://app.bharosasms.com/api/v1/sms/send/ \ -H "X-API-KEY: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "to": ["98XXXXXXXX", "97XXXXXXXX"], "text": "Hello from Bharosa SMS!", "sender_id": { "NT": "YourSenderID", "Ncell": "YourSenderID" }, "message_type": "plain" }' # ── Scheduled send ──────────────────────────────────── curl -X POST https://app.bharosasms.com/api/v1/sms/send/ \ -H "X-API-KEY: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "to": ["98XXXXXXXX"], "text": "Your appointment is tomorrow at 10am.", "sender_id": { "NT": "CLINIC", "Ncell": "CLINIC" }, "message_type": "plain", "scheduled_at": "2026-04-20 09:00:00" }' # ── Nepali unicode ──────────────────────────────────── curl -X POST https://app.bharosasms.com/api/v1/sms/send/ \ -H "X-API-KEY: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "to": ["98XXXXXXXX"], "text": "नमस्ते! हाम्रो सेवामा स्वागत छ।", "sender_id": { "NT": "MYAPP", "Ncell": "MYAPP" }, "message_type": "unicode" }'
// Node 18+ has built-in fetch. For older versions: npm install node-fetch const API_KEY = process.env.BHAROSA_API_KEY; const ENDPOINT = 'https://app.bharosasms.com/api/v1/sms/send/'; async function sendSMS({ to, text, senderNT, senderNcell, messageType = 'plain', scheduledAt = null }) { const body = { to: Array.isArray(to) ? to : [to], text, sender_id: { NT: senderNT, Ncell: senderNcell }, message_type: messageType, ...(scheduledAt && { scheduled_at: scheduledAt }), }; const res = await fetch(ENDPOINT, { method: 'POST', headers: { 'X-API-KEY': API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify(body), }); if (!res.ok) { const err = await res.json(); throw new Error(err.error || err.detail); } return res.json(); // → { message, batch_id, cost, pages, failed_numbers } } // ── Plain send ──────────────────────────────────────── const result = await sendSMS({ to: ['98XXXXXXXX', '97XXXXXXXX'], text: 'Hello from Node.js!', senderNT: 'MYAPP', senderNcell: 'MYAPP', }); console.log(`Batch: ${result.batch_id} | Cost: ${result.cost}`); // ── Scheduled send ──────────────────────────────────── await sendSMS({ to: '98XXXXXXXX', text: 'Reminder: appointment tomorrow at 10am.', senderNT: 'CLINIC', senderNcell: 'CLINIC', scheduledAt: '2026-04-20 09:00:00', }); // ── Nepali unicode ──────────────────────────────────── await sendSMS({ to: '98XXXXXXXX', text: 'नमस्ते! हाम्रो सेवामा स्वागत छ।', senderNT: 'MYAPP', senderNcell: 'MYAPP', messageType: 'unicode', });
import os import requests API_KEY = os.environ["BHAROSA_API_KEY"] ENDPOINT = "https://app.bharosasms.com/api/v1/sms/send/" HEADERS = {"X-API-KEY": API_KEY, "Content-Type": "application/json"} def send_sms(to, text, sender_nt, sender_ncell, message_type="plain", scheduled_at=None): """ to : str | list[str] text : str sender_nt : str NTC sender ID sender_ncell : str Ncell sender ID message_type : "plain" | "unicode" (unicode for Nepali text) scheduled_at : str | None "YYYY-MM-DD HH:MM:SS" """ payload = { "to": [to] if isinstance(to, str) else to, "text": text, "sender_id": {"NT": sender_nt, "Ncell": sender_ncell}, "message_type": message_type, } if scheduled_at: payload["scheduled_at"] = scheduled_at r = requests.post(ENDPOINT, json=payload, headers=HEADERS) r.raise_for_status() # raises HTTPError on 4xx / 5xx return r.json() # ── Plain send ──────────────────────────────────────── result = send_sms( to=["98XXXXXXXX", "97XXXXXXXX"], text="Hello from Python!", sender_nt="MYAPP", sender_ncell="MYAPP", ) print(f"Batch {result['batch_id']} | Cost: {result['cost']}") # ── Scheduled send ──────────────────────────────────── send_sms( to="98XXXXXXXX", text="Reminder: your appointment is tomorrow.", sender_nt="CLINIC", sender_ncell="CLINIC", scheduled_at="2026-04-20 09:00:00", ) # ── Nepali unicode ──────────────────────────────────── send_sms( to="98XXXXXXXX", text="नमस्ते! हाम्रो सेवामा स्वागत छ।", sender_nt="MYAPP", sender_ncell="MYAPP", message_type="unicode", )
<?php // Store your key in .env — never hardcode it $apiKey = $_ENV['BHAROSA_API_KEY']; $endpoint = 'https://app.bharosasms.com/api/v1/sms/send/'; function sendSMS( array $to, string $text, string $senderNT, string $senderNcell, string $messageType = 'plain', ?string $scheduledAt = null ): array { global $apiKey, $endpoint; $payload = [ 'to' => $to, 'text' => $text, 'sender_id' => ['NT' => $senderNT, 'Ncell' => $senderNcell], 'message_type' => $messageType, ]; if ($scheduledAt) $payload['scheduled_at'] = $scheduledAt; $ch = curl_init($endpoint); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'X-API-KEY: ' . $apiKey, 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => json_encode($payload), ]); $body = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $data = json_decode($body, true); if ($status >= 400) throw new Exception($data['error'] ?? $data['detail']); return $data; } // ── Plain send ──────────────────────────────────────── $r = sendSMS(['98XXXXXXXX', '97XXXXXXXX'], 'Hello from PHP!', 'MYAPP', 'MYAPP'); echo "Batch: {$r['batch_id']} | Cost: {$r['cost']}"; // ── Scheduled send ──────────────────────────────────── sendSMS(['98XXXXXXXX'], 'Appointment tomorrow 10am.', 'CLINIC', 'CLINIC', 'plain', '2026-04-20 09:00:00'); // ── Nepali unicode ──────────────────────────────────── sendSMS(['98XXXXXXXX'], 'नमस्ते! हाम्रो सेवामा स्वागत छ।', 'MYAPP', 'MYAPP', 'unicode'); ?>
Official SDKs wrap the API so you don't need to handle HTTP yourself. Don't see your language? The REST API works with any HTTP client.
No surprises. No hidden limits. Here's what you get with every API account.
message_type: "unicode" and the API handles encoding.