SMSGatewayCenter provides a flexible and robust SMS API to enable developers to send SMS messages programmatically through the https://unify.smsgateway.center/SMSApi/send
endpoint. This article outlines the four primary API types supported for sending SMS messages, including XML, Form Data, JSON, x-www-form-urlencoded, and Query Parameter-based REST APIs. Each method offers unique advantages, use cases, and considerations for integration into your applications.
1. XML API #
The XML API allows you to send SMS messages by structuring data in XML format within the request body. This method is ideal for applications that already use XML for data exchange or require a structured, hierarchical format.
Example Request #
curl --location 'https://unify.smsgateway.center/SMSApi/send' \
--header 'Content-Type: application/xml' \
--header 'Accept: application/xml' \
--header 'Cookie: SERVERID=webC2' \
--data '<data>
<userid>YourUsername</userid>
<password>********</password>
<senderid>SENDER</senderid>
<msgType>text</msgType>
<dltEntityId>xxxxxxxxxxxxx</dltEntityId>
<dltTemplateId>xxxxxxxxxxxxx</dltTemplateId>
<duplicatecheck>true</duplicatecheck>
<sendMethod>quick</sendMethod>
<sms>
<mobile>919xxxxxxxx1</mobile>
<msg>hello world again</msg>
</sms>
<sms>
<mobile>919xxxxxxxx2</mobile>
<msg>hello world again</msg>
</sms>
</data>'
Key Features #
- Format: Uses
application/xml
as theContent-Type
andAccept
headers. - Structure: Data is organized in a hierarchical XML structure, wrapped in a
<data>
root element with nested elements like<userid>
,<password>
, and<sms>
. - Use Case: Suitable for legacy systems, XML-based integrations, or applications requiring XML parsing.
Considerations #
- Ensure proper XML formatting to avoid parsing errors.
- Requires careful handling of special characters (e.g., encode
<
,>
,&
in XML). - May be less common for modern APIs compared to JSON but offers robust structure for complex data.
2. Form Data API #
The Form Data API, also known as Multipart Form Data API, sends SMS data as key-value pairs in the request body, mimicking HTML form submissions. This method is simple and widely supported, making it ideal for basic integrations or scenarios involving file uploads.
Example Request #
curl --location --globoff 'https://unify.smsgateway.center/SMSApi/send' \
--form 'userid="YourUsername"' \
--form 'password="••••••"' \
--form 'mobile="919619761646"' \
--form 'senderid="{{SENDER_NAME}}"' \
--form 'dltEntityId="{{DLT_ENTITY_ID}}"' \
--form 'msg="This is testing"' \
--form 'sendMethod="quick"' \
--form 'msgType="text"' \
--form 'dltTemplateId="1234"' \
--form 'output="json"' \
--form 'duplicatecheck="true"'
Key Features #
- Format: Uses
multipart/form-data
implicitly viacurl --form
, sending data as key-value pairs. - Structure: Flat key-value pairs (e.g.,
userid=YourUsername
,msg=This is testing
) without hierarchical nesting. - Use Case: Ideal for simple applications, browser-compatible forms, or when uploading files alongside SMS data.
Considerations #
- Limited to flat structures, making it less suitable for complex, nested data.
- Data is exposed in the request body, so use HTTPS for security.
- Less common for modern RESTful APIs but useful for legacy or form-based systems.
3. JSON API #
The JSON API sends SMS data in JavaScript Object Notation (JSON) format within the request body. This is the most popular format for modern RESTful APIs due to its simplicity, readability, and widespread support in programming languages.
Example Request #
curl --location 'https://unify.smsgateway.center/SMSApi/send' \
--header 'Content-Type: application/json' \
--header 'Cookie: SERVERID=webC2' \
--data '{
"userid": "YourUsername",
"password": "********",
"senderid": "SENDER",
"msgType": "text",
"dltEntityId": "xxxxxxxxxxxxx",
"dltTemplateId": "xxxxxxxxxxxxx",
"duplicatecheck": "true",
"sendMethod": "quick",
"sms": [
{
"mobile": [
"919xxxxxxxx1"
],
"msg": "hello world again"
},
{
"mobile": [
"919xxxxxxxx2"
],
"msg": "Final last msg"
}
]
}'
Key Features #
- Format: Uses
application/json
as theContent-Type
header. - Structure: Data is organized as a JSON object with key-value pairs and nested arrays/objects (e.g.,
"sms": [{}, {}]
). - Use Case: Preferred for modern web and mobile applications, APIs, and integrations requiring structured, lightweight data.
Considerations #
- Requires JSON parsing on both client and server sides, but most languages and frameworks support it natively.
- Ensures clean, human-readable data, but improper formatting (e.g., missing commas, quotes) can cause errors.
- Ideal for complex, nested data structures, making it more flexible than Form Data.
4. Query Parameter-based REST API #
The Query Parameter-based REST API uses HTTP GET
with query parameters in the URL to send bulk SMS data. This method is stateless, lightweight, and browser-friendly, making it suitable for simple operations or direct testing.
Example Request #
curl -X GET \
'https://unify.smsgateway.center/SMSApi/send?userId=user&password=*******&senderId=SMSGAT&sendMethod=simpleMsg&msgType=text&mobile=9199999999999&msg=This%20is%20my%20first%20message%20with%20SMSGateway.Center&duplicateCheck=true&format=json&scheduleTime=2017-06-13%2020%3A22%3A00' \
-H 'cache-control: no-cache'
Key Features #
- Format: Data is sent as query parameters in the URL (e.g.,
?userid=user&password=userpass
). - Structure: Flat key-value pairs encoded in the URL, with the response specified as JSON (
format=json
). - Use Case: Ideal for simple GET requests, browser testing, or APIs with small, non-sensitive data.
Considerations #
- URL length limits (~2000 characters) restrict its use for large or complex data.
- Exposes data in the URL, so avoid sensitive information (e.g.,
password=userpass
) in production—use HTTPS and considerPOST
for secure data. - Less flexible for structured or nested data compared to JSON or XML but easy to test with tools like
curl
or browsers.
5. x-www-form-urlencoded API #
The x-www-form-urlencoded API sends SMS data as URL-encoded key-value pairs in the request body, typically used with the POST method. This method is simple, lightweight, and compatible with browser-based forms, making it ideal for basic text-based integrations without file uploads.
Example Request #
curl --location --globoff 'https://unify.smsgateway.center/SMSApi/send' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'userid=YourUsername' \
...
--data-urlencode 'mobile=919xxxxxxxxxxx'
Key Features #
- Format: Uses application/x-www-form-urlencoded as the Content-Type header.
- Structure: Flat key-value pairs encoded as key1=value1&key2=value2, with special characters URL-encoded (e.g., spaces become + or %20).
- Use Case: Suitable for simple APIs, browser-compatible forms, or applications requiring compact, text-only data without files.
Considerations #
- Cannot handle file uploads or binary data, limiting its use to text-based data.
- Less suitable for complex or nested data due to its flat structure.
- Lightweight and widely supported, but less common for modern RESTful APIs compared to JSON.
Choosing the Right API Type #
- XML API: Use for legacy systems, XML-based integrations, or when hierarchical data is required.
- Form Data API: Use for simple integrations, form submissions, or file uploads alongside SMS data.
- JSON API: Use for modern, RESTful applications requiring structured, lightweight data and broad language support.
- Query Parameter-based REST API: Use for simple GET requests, direct browser testing, or stateless operations with small data.
- x-www-form-urlencoded API: Use for simple, text-based APIs or browser forms without files, offering a lightweight alternative to Form Data.
Security and Best Practices #
- Use HTTPS: Always use HTTPS to encrypt data in transit, especially for sensitive information like
password
oruserId
. - Authenticate Requests: Implement API keys, token-based authentication to secure access.
- Validate Data: Ensure server-side validation for all input data to prevent injection attacks or malformed requests.
- Limit Origins: Use CORS policies (
Access-Control-Allow-Origin
) to restrict API access to trusted clients. - Rate Limiting: Apply rate limits to prevent abuse and ensure fair usage.
Troubleshooting #
- Response Format: Verify the
format
parameter (e.g.,json
) matches your expected output and handle parsing accordingly. - Network Issues: Check server availability, DNS, and firewall settings if requests fail.
For further assistance, contact our support team at [email protected] or refer to our API Documentation.