0% found this document useful (0 votes)
29 views6 pages

Business SMS API Documentation

The Business SMS API allows authenticated clients to send SMS messages to Pakistani numbers using a specified sender name. It provides a POST endpoint for sending messages, requiring parameters such as username, password, masking, recipient number, and message content. The documentation includes usage instructions, code examples in various programming languages, and notes on formatting and balance requirements.

Uploaded by

Realism 360
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views6 pages

Business SMS API Documentation

The Business SMS API allows authenticated clients to send SMS messages to Pakistani numbers using a specified sender name. It provides a POST endpoint for sending messages, requiring parameters such as username, password, masking, recipient number, and message content. The documentation includes usage instructions, code examples in various programming languages, and notes on formatting and balance requirements.

Uploaded by

Realism 360
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

BUSINESS SMS API

BUSINESS SMS API – Client Documentation


Base URL:
[Link]

Swagger UI (API Test Interface):


[Link]

1. API Overview
This API allows authenticated clients to send SMS messages to Pakistani numbers using
their assigned masking (sender name). It supports GET (direct URL call) and POST
(Swagger, code, or HTTP client).

2. Endpoints

POST – SendSMS
URL:
POST [Link]

Parameter Type Required Description

username string Yes Your account


username

password string Yes Your account


password

masking string Yes Sender name


assigned to your
account

sendTo string Yes Recipient number in


international format
(e.g.,
923001234567)

message string Yes SMS text content

language string No "English" (default)


or "Urdu"

Example Request URL (GET method)


[Link]
o&masking=MASKING&sendTo=923xxxxxxxxx&message=Hello%20World!&language=En
glish
Success Response (200 OK)
{
"Status": "Success",
"Message": "SMS sent to 923xxxxxxxxx in English."
}

Error Responses
401 Unauthorized – Invalid username/password

400 Bad Request – Insufficient balance / Incorrect masking / Missing parameters

3. How to Use
Option 1 – Swagger Web Interface:
a) Open Swagger URL
b) Expand POST /api/SMS/SendSMS
c) Enter your parameters
d) Click 'Try it out'

Option 2 – Direct URL Call (GET Method): Paste the above GET URL in a browser or run
from any HTTP client.

4. Code Examples

C# (Console or WinForms/WPF)
using System;
using [Link];
using [Link];

class Program
{
static async Task Main()
{
using (HttpClient client = new HttpClient())
{
var url = "[Link] var
content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("username", "demo"),
new KeyValuePair<string, string>("password", "demo"),
new KeyValuePair<string, string>("masking", "MASKING"),
new KeyValuePair<string, string>("sendTo", "923xxxxxxxxx"),
new KeyValuePair<string, string>("message", "Hello World!"),
new KeyValuePair<string, string>("language", "English")
});
var response = await [Link](url, content);
string result = await [Link]();
[Link](result);
}
}
}

[Link] (Server-Side Call)


using [Link];
using [Link];

public class SmsService


{
public async Task<string> SendSms()
{
using (HttpClient client = new HttpClient())
{
var url = "[Link] var
content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("username", "demo"),
new KeyValuePair<string, string>("password", "demo"),
new KeyValuePair<string, string>("masking", "MASKING"),
new KeyValuePair<string, string>("sendTo", "923xxxxxxxxx"),
new KeyValuePair<string, string>("message", "Hello from [Link]"),
new KeyValuePair<string, string>("language", "English")
});

var response = await [Link](url, content);


return await [Link]();
}
}
}

Java
import [Link].*;
import [Link].*;
import [Link];

public class SmsClient {


public static void main(String[] args) throws Exception {
String urlParameters =
"username=demo&password=demo&masking=TIMEGATE&sendTo=923xxxxxxxxx&messag
e=Hello%20World!&language=English";
byte[] postData = [Link](StandardCharsets.UTF_8);

URL url = new URL("[Link]


HttpURLConnection conn = (HttpURLConnection) [Link]();
[Link](true);
[Link]("POST");
[Link]("Content-Type", "application/x-www-form-urlencoded");

try (DataOutputStream wr = new DataOutputStream([Link]())) {


[Link](postData);
}

BufferedReader in = new BufferedReader(new


InputStreamReader([Link]()));
String inputLine;
StringBuilder response = new StringBuilder();

while ((inputLine = [Link]()) != null) {


[Link](inputLine);
}
[Link]();

[Link]([Link]());
}
}

PHP
<?php
$url = "[Link]

$data = array(
'username' => 'demo',
'password' => 'demo',
'masking' => 'MASKING',
'sendTo' => '923xxxxxxxxx',
'message' => 'Hello World!',
'language' => 'English'
);

$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
)
);

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

if ($result === FALSE) {


die('Error sending SMS');
}

echo $result;
?>

5. Notes
- Numbers must be in international format without + (e.g., 923xxxxxxxxx).
- Balance is deducted based on message length: 1 unit per 160 characters.
- Masking must be pre-approved and assigned to your account.
- Ensure you have sufficient balance before sending messages.

Common questions

Powered by AI

The international format requirement ensures consistency and compatibility of SMS delivery globally. By mandating numbers in this format, the BUSINESS SMS API facilitates integration with international telecom standards, reducing errors related to formatting inconsistencies. This requirement supports robust globalization strategies by allowing businesses to seamlessly reach an international audience with minimal adjustments, resulting in efficient cross-border communication .

Users can ensure their SMS messages reach recipients by adhering to the documentation's guidelines: using proper international format for numbers, verifying their masking is pre-approved and assigned, ensuring ample balance by keeping track of message lengths, and double-checking all required parameters in API requests. By following these steps, users reduce the risk of errors and improve message delivery rates .

The BUSINESS SMS API offers flexibility in message content configuration by allowing users to choose the language of the SMS, with options for English and Urdu. This feature benefits users by enabling them to target diverse audiences effectively, catering to the linguistic preferences of recipients. Additionally, the API supports varying message content lengths, which accommodates different communication needs while managing balance efficiently .

Pre-approved masking in the BUSINESS SMS API offers several advantages. It adds a layer of validation and security, as only authorized sender names (masking) are allowed, preventing spoofing or unauthorized use of sender identities. This practice enhances the credibility of the messages sent and ensures compliance with regulations regarding sender identity. Additionally, it helps in building brand recognition since recipients can easily identify the sender .

Critical considerations for developers implementing the BUSINESS SMS API include understanding HTTP request structures in different programming environments, ensuring secure transmission of sensitive parameters (e.g., credentials), and managing asynchronous operations for API calls. Developers must also handle response interpretation correctly for error management and utilize the API's capabilities like language selection and masking to meet client requirements. Language-specific idioms and libraries, such as C# async tasks or PHP stream contexts, are essential for effective implementation .

The BUSINESS SMS API ensures that messages are sent from authenticated clients by requiring users to provide a valid username and password. This authentication step verifies the credentials against the system. Additionally, the sender name, also known as masking, must be pre-approved and assigned to the user's account, ensuring that only authorized sender names are used for sending messages .

The BUSINESS SMS API supports sending SMS via both GET and POST methods. The POST method is primarily used through the Swagger web interface, allowing users to enter parameters directly and receive immediate responses. In contrast, the GET method involves constructing a direct URL call that can be executed in a browser or any HTTP client. The POST method typically provides better security for sensitive information such as passwords as compared to GET, where such information can be exposed in the URL .

The Swagger interface offers several benefits for sending SMS through the BUSINESS SMS API. It provides a user-friendly GUI for entering request parameters directly, which simplifies testing and avoids manual errors in request construction. The interface also immediately displays response status and messages, facilitating quick validation of successful or error responses. These capabilities enhance ease of use, especially for users who prefer a visual interface over direct coding or URL configuration .

The BUSINESS SMS API calculates balance deductions based on the message length, with 1 unit deducted per 160 characters. This calculation method is important for users to understand as it directly impacts the cost of sending messages and requires users to ensure they have a sufficient balance to cover the costs of their communications. Misunderstanding these deductions could lead to unexpected costs or sending errors due to insufficient balance .

Error responses in the BUSINESS SMS API can result from issues such as invalid username/password combinations, insufficient balance, incorrect masking, or missing parameters. A 401 Unauthorized error indicates authentication failure due to invalid credentials, while a 400 Bad Request may arise from insufficient balance or incorrect masking. These errors prevent SMS messages from being sent successfully, thereby affecting the API's primary functionality of delivering messages to target recipients .

You might also like