SMS API v1
An SMS API that behaves the way you expect
JSON over HTTPS, Bearer API keys, idempotent sends, signed webhooks and consistent errors. Integrate from any language in an afternoon.
curl -X POST https://sms.marketian.net/api/v1/sms/send \
-H "Authorization: Bearer $MZSMS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-10234-otp" \
-d '{
"to": "+8801XXXXXXXXX",
"message": "Your verification code is 123456",
"sender_id": "YOURBRAND",
"type": "transactional"
}'REST API overview
- Base URL
- https://sms.marketian.net/api/v1
- Format
- JSON request and response bodies, UTF-8
- Authentication
- Authorization: Bearer <api key>
- Versioning
- Path-based (/api/v1). Breaking changes only ship in a new version.
- Numbers
- Bangladesh mobile numbers in any common format; returned as +8801XXXXXXXXX
- Time
- ISO 8601 timestamps in UTC; the dashboard displays Asia/Dhaka
| Endpoint | Scope |
|---|---|
POST/api/v1/sms/send Send one SMS | sms:send |
POST/api/v1/sms/bulk Send up to 1,000 SMS in one request | sms:send |
Calculate segments and cost without sending | sms:send |
Get a message and its delivery events | messages:read |
List messages with filters | messages:read |
Wallet balance and your rates | balance:read |
List your sender IDs and their status | sender_ids:read |
About delivery in this environment
Authentication and API keys
Create keys in Dashboard → API. Each key belongs to one organization and carries only the scopes you grant.
- Keys look like sfk_live_xxxxxxxx_… and are shown exactly once when created. Store them in a secret manager.
- We store only a keyed hash of the key, so we can't show it again. Lost keys are revoked and replaced.
- Restrict a key to your server's IP addresses and set an expiry for temporary integrations.
- Never put an API key in a mobile app, browser JavaScript or a public repository.
{
"to": "+8801XXXXXXXXX",
"message": "Your verification code is 123456",
"sender_id": "YOURBRAND",
"type": "transactional"
}{
"success": true,
"data": {
"message_id": "5b0f2c7e-7a55-4b1e-9d0a-3c1d2e4f6a70",
"to": "+8801XXXXXXXXX",
"status": "queued",
"segments": 1,
"encoding": "GSM7",
"cost": "0.35",
"currency": "BDT"
},
"meta": { "requestId": "req_8f2k1m0q7x3v9b2n" }
}Bulk sending, status and balance
The bulk endpoint accepts per-recipient variables. Status lookups include the full event history.
Bulk SMS
curl -X POST https://sms.marketian.net/api/v1/sms/bulk \
-H "Authorization: Bearer $MZSMS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sender_id": "YOURBRAND",
"type": "transactional",
"message": "Hi {{name}}, your order {{order}} has shipped.",
"recipients": [
{ "to": "+8801XXXXXXXXX", "variables": { "name": "Rahim", "order": "#1001" } },
{ "to": "01XXXXXXXXX", "variables": { "name": "Karima", "order": "#1002" } }
]
}'Delivery report
curl https://sms.marketian.net/api/v1/messages/5b0f2c7e-7a55-4b1e-9d0a-3c1d2e4f6a70 \
-H "Authorization: Bearer $MZSMS_API_KEY"Balance
curl https://sms.marketian.net/api/v1/balance -H "Authorization: Bearer $MZSMS_API_KEY"Webhooks
Register an HTTPS endpoint in Dashboard → API → Webhooks and choose events: message.delivered, message.failed, campaign.completed.
- Each request has an X-SMSFlow-Signature header: t=timestamp,v1=HMAC-SHA256(secret, "t.body").
- Respond with any 2xx within 10 seconds. Failed deliveries retry with exponential backoff, up to 8 attempts.
- Deliveries can repeat; deduplicate with the payload id.
{
"id": "d2c1b9e0-...",
"event": "message.delivered",
"created_at": "2026-09-30T08:15:10.002Z",
"data": {
"message_id": "5b0f2c7e-7a55-4b1e-9d0a-3c1d2e4f6a70",
"to": "+8801XXXXXXXXX",
"status": "delivered",
"error_code": null,
"segments": 1,
"cost": "0.35",
"refunded": false,
"client_reference": "order-10234",
"campaign_id": null,
"occurred_at": "2026-09-30T08:15:09.771Z"
}
}Verify the signature
import crypto from "node:crypto";
// Express: use the raw body, not the parsed JSON, when computing the signature.
app.post("/webhooks/sms", express.raw({ type: "application/json" }), (req, res) => {
const header = req.get("X-SMSFlow-Signature") ?? ""; // "t=1727683200,v1=5d41..."
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const expected = crypto
.createHmac("sha256", process.env.MZSMS_WEBHOOK_SECRET)
.update(`${t}.${req.body}`)
.digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
if (!fresh || !crypto.timingSafeEqual(Buffer.from(v1 ?? ""), Buffer.from(expected))) {
return res.status(400).send("invalid signature");
}
const event = JSON.parse(req.body);
// Deduplicate on event.id: the same delivery can be retried.
res.sendStatus(200);
});Rate limits, retries and errors
Rate limits
Default 600 requests/minute per key, 120/minute for send endpoints. See X-RateLimit-* headers.
Idempotency
Idempotency-Key header on POST /sms/*: replays within 24 hours return the original response.
Consistent errors
Every error has a stable code, a readable message and a request ID for support.
Account limits
Daily and monthly send limits protect you from runaway loops. Ask support to raise them.
| Code | HTTP | Meaning |
|---|---|---|
| INVALID_REQUEST The request is malformed (invalid JSON, body too large, bad header). | 400 | The request is malformed (invalid JSON, body too large, bad header). |
| VALIDATION_ERROR One or more fields are invalid. See error.details.fields. | 422 | One or more fields are invalid. See error.details.fields. |
| INVALID_API_KEY The API key is missing, malformed, revoked or expired. | 401 | The API key is missing, malformed, revoked or expired. |
| FORBIDDEN Authenticated but not allowed (IP not allowlisted, account suspended, missing permission). | 403 | Authenticated but not allowed (IP not allowlisted, account suspended, missing permission). |
| INSUFFICIENT_SCOPE The API key does not have the scope this endpoint requires. | 403 | The API key does not have the scope this endpoint requires. |
| ACCOUNT_SUSPENDED The organization is suspended. Contact support. | 403 | The organization is suspended. Contact support. |
| NOT_FOUND The resource does not exist or belongs to another account. | 404 | The resource does not exist or belongs to another account. |
| CONFLICT The request conflicts with the current state (e.g. a duplicate, or a request with the same Idempotency-Key still in progress). | 409 | The request conflicts with the current state (e.g. a duplicate, or a request with the same Idempotency-Key still in progress). |
| IDEMPOTENCY_CONFLICT The Idempotency-Key was already used with a different request body. | 409 | The Idempotency-Key was already used with a different request body. |
| RATE_LIMITED Too many requests. Wait for the time in the Retry-After header. | 429 | Too many requests. Wait for the time in the Retry-After header. |
| INSUFFICIENT_BALANCE Wallet balance is lower than the cost of the request. | 402 | Wallet balance is lower than the cost of the request. |
| INVALID_RECIPIENT The number is not a valid Bangladesh mobile number, or is blocked. | 422 | The number is not a valid Bangladesh mobile number, or is blocked. |
Build with the SMS API
Create an account, generate a scoped key, and follow the quick start.