callpro-sms
v1.0.0
Published
CallPro SMS (MessagePro) SDK for Node.js
Maintainers
Readme
callpro-sms
CallPro SMS (MessagePro) SDK for Node.js — send SMS, check delivery status, fetch messages, and run bulk campaigns via the CallPro API.
Installation
npm install callpro-smsQuick Start
import { CallPro } from "callpro-sms";
const client = new CallPro({
apiKey: "your-api-key",
from: "your-registered-phone-number",
endpoint: "https://api.callpro.mn/messagepro",
});
// Send an SMS
const result = await client.sendMessage("99112233", "Hello from CallPro!");
console.log(result["Message ID"]); // 12345API Reference
new CallPro(config)
Create a new client instance.
| Parameter | Type | Description |
| --- | --- | --- |
| config.apiKey | string | Your CallPro API key |
| config.from | string | Your registered sender phone number |
| config.endpoint | string | CallPro API base URL |
sendMessage(to, text)
Send an SMS message to a single recipient.
const result = await client.sendMessage("99112233", "Your OTP is 1234");Parameters:
| Name | Type | Description |
| --- | --- | --- |
| to | string | Recipient phone number |
| text | string | Message content |
Returns: Promise<SendResponse>
{
Result: "success",
"Message ID": 12345,
Reason?: "optional error reason"
}getStatus(messageId)
Check the delivery status of a sent message.
const status = await client.getStatus("12345");Parameters:
| Name | Type | Description |
| --- | --- | --- |
| messageId | string | The message ID returned from sendMessage |
Returns: Promise<GetStatusResponse>
{
delivered: "yes",
result: "success",
source_number: "70001234",
destination_number: "99112233",
text: "Your OTP is 1234"
}fetchMessage(from, text)
Fetch incoming messages.
const response = await client.fetchMessage("99112233", "CONFIRM");Parameters:
| Name | Type | Description |
| --- | --- | --- |
| from | string | Sender phone number |
| text | string | Message text to match |
Returns: Promise<string>
orderCampaign(campaign)
Send bulk SMS via a campaign.
// Same text to multiple numbers
await client.orderCampaign({
name: "Promo Campaign",
isWithText: 0,
text: "Flash sale today!",
from: "70001234",
begin_date: "20260301",
begin_hour: "09",
begin_minute: "00",
numbers: ["99112233", "99445566", "99778899"],
});
// Unique text per number
await client.orderCampaign({
name: "OTP Campaign",
isWithText: 1,
text: "",
from: "70001234",
begin_date: "20260301",
begin_hour: "09",
begin_minute: "00",
numbers: [
{ number: "99112233", text: "Your code is 1111" },
{ number: "99445566", text: "Your code is 2222" },
],
});Parameters:
| Name | Type | Description |
| --- | --- | --- |
| campaign.name | string | Campaign name |
| campaign.isWithText | 0 \| 1 | 0 = same text to all numbers, 1 = unique text per number |
| campaign.text | string | Message text (used when isWithText is 0) |
| campaign.from | string | Sender phone number |
| campaign.begin_date | string | Start date in YYYYMMDD format |
| campaign.begin_hour | string | Start hour (00-23) |
| campaign.begin_minute | string | Start minute (00-59) |
| campaign.numbers | string[] \| NumberData[] | Recipients — array of phone strings or { number, text } objects |
Returns: Promise<string>
TypeScript
All types are exported:
import type {
CallProConfig,
SendResponse,
GetStatusResponse,
OrderCampaignRequest,
NumberData,
} from "callpro-sms";Requirements
- Node.js 18+ (uses native
fetch)
License
ISC
