How to Send SMS Through API

Alpha SMS API is a RESTful API that lets you send SMS messages from your software or application in Bangladesh. You can use both GET and POST methods to make requests to the API endpoint. The API supports JSON format for both requests and responses, making it easy to integrate with any platform. To get started, you need to obtain your API Key from the SMS Panel in "API" page and follow the instructions below.

Find our open-source projects and contribute on GitHub:

GitHub Profile
Send SMS
Endpoint
https://api.sms.net.bd/sendsms
Parameters
Name Meaning
api_key Required. Your API KEY is used to authenticate in our system.
msg Required. The body content of your message.
to Required. The recipient numbers. Multiple numbers must be separated by comma(,). The Number must start with country code(880) or Standard 01X.
schedule Optional. The schedule date and time to send your message. Date and time must be formatted as Y-m-d H:i:s (eg. 2021-10-13 16:00:52 )
sender_id Optional. If you have an approved Sender ID, you can use this parameter to set your Sender ID as from in you messages.
Request
https://api.sms.net.bd/sendsms?api_key={YOUR_API_KEY}&msg={YOUR_MSG}&to=8801800000000,8801700000000&schedule=2021-10-13 16:00:52
Response

{
    "error": 0,
    "msg": "Request successfully submitted",
    "data": {
        "request_id": 0000
    }
}
Report API
Endpoint
https://api.sms.net.bd/report/request/{id}/
Parameters
Name Meaning
api_key Required. Your API KEY is used to authenticate in our system.
Request
https://api.sms.net.bd/report/request/{id}/?api_key={YOUR_API_KEY}
Response

{
  "error": 0,
  "msg": "Success",
  "data": {
    "request_id": 0000,
    "request_status": "Complete",
    "request_charge": "0.0000",
    "recipients": [
      {
        "number": "8801800000000",
        "charge": "0.0000",
        "status": "Sent"
      }
    ]
  }
}
Balance API
Endpoint
https://api.sms.net.bd/user/balance/
Parameters
Name Meaning
api_key Required. Your API KEY is used to authenticate in our system.
Request
https://api.sms.net.bd/user/balance/?api_key={YOUR_API_KEY}
Response

{
  "error": 0,
  "msg": "Success",
  "data": {
    "balance": "00.0000"
  }
}
Error Codes
Common Errors
Error - 0 Success. Everything worked as expected.
Error - 400 The request was rejected, due to a missing or invalid parameter.
Error - 403 You don't have permissions to perform the request.
Error - 404 The requested resource not found.
Error - 405 Authorization required.
Error - 409 Unknown error occurred on Server end.
Send SMS Errors
Error - 410 Account expired
Error - 411 Reseller Account expired or suspended
Error - 412 Invalid Schedule
Error - 413 Invalid Sender ID
Error - 414 Message is empty
Error - 415 Message is too long
Error - 416 No valid number found
Error - 417 Insufficient balance
Error - 420 Content Blocked

SMS API Codes samples in popular languages.

We have included code samples for sending SMS in PHP, C#, Python, Java, NodeJS etc. Choose your choice of Language from the tabs below to view SMS API Code samples.


curl -X "POST" https://api.sms.net.bd/sendsms \
     -d api_key=YOUR_API_KEY \
     -d msg=Test \
     -d to=8801800000000
import requests

url = "https://api.sms.net.bd/sendsms"

payload = {'api_key': 'YOUR_API_KEY',
    'msg': 'Test',
    'to': '8801800000000'
}

response = requests.request("POST", url, data=payload)
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.sms.net.bd/sendsms',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('api_key' => 'YOUR_API_KEY','msg' => 'Test','to' => '8801800000000'),
));

$response = curl_exec($curl);

curl_close($curl);

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.sms.net.bd/sendsms")
  .multiPartContent()
  .field("api_key", "YOUR_API_KEY")
  .field("msg", "Test")
  .field("to", "8801800000000")
  .asString();

const axios = require('axios');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.sms.net.bd/sendsms',
  headers: { 
    'Content-Type': 'application/json'
  },
  data : JSON.stringify({
	  "api_key": "YOUR_API_KEY",
	  "msg": "JSON API Testing",
	  "to": "8801800000000"
	})
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});


//Adding Library
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json; //Adding New Package Newtonsoft


public class Program
{
    public static void Main(string[] args)
    {
        using (var client = new HttpClient())
        {
            string API_Url = "https://api.sms.net.bd/sendsms";
            string API_Key = "YOUR_API_KEY";
            string Text_Massage = "YOUR_MSG";
            string To_Phone_Number = "NUMBER_TO_SEND";
    
            client.BaseAddress = new Uri(API_Url);// //
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var response = client.GetAsync("?api_key=" + API_Key + "&msg=" + Text_Massage + "&to=" + To_Phone_Number).Result;
            using (HttpContent content = response.Content)
            {
                var bkresult = content.ReadAsStringAsync().Result;
                dynamic stuff = JsonConvert.DeserializeObject(bkresult);
                if (stuff.error == "0")
                {
                    Console.WriteLine(stuff.msg);
                }
                else
                {
                    Console.WriteLine("Sms Not Send, " + stuff.msg);
                }

            }
        }
    }
}


/*---------------------------------------------------------------------------------------------------------------------------*/

// Example 2 with JSON

using Newtonsoft.Json;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

public class Program
{
    public static async Task Main(string[] args)
    {
        using (var client = new HttpClient())
        {
            string API_Url = "https://api.sms.net.bd/sendsms";
            string API_Key = "YOUR_API_KEY";
            string Text_Massage = "YOUR_MSG";
            string To_Phone_Number = "NUMBER_TO_SEND";

            client.BaseAddress = new Uri(API_Url);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var requestData = new
            {
                api_key = API_Key,
                msg = Text_Massage,
                to = To_Phone_Number
            };

            var content = new StringContent(JsonConvert.SerializeObject(requestData), Encoding.UTF8, "application/json");

            var response = await client.PostAsync(API_Url, content);

            if (response.IsSuccessStatusCode)
            {
                var responseContent = await response.Content.ReadAsStringAsync();
                dynamic result = JsonConvert.DeserializeObject(responseContent);

                if (result.error == "0")
                {
                    await Console.Out.WriteLineAsync(Convert.ToString(result));
                }
                else
                {
                    await Console.Out.WriteLineAsync($"Error: {Convert.ToString(result.error)}, {Convert.ToString(result.msg)}");
                }
            }
        }
    }
}

Postman Example

SMS API supports both GET and POST request and supports JSON format for request and response.

SMS JSON API Postman Example

WordPress Plugin

Keep your customers happy with automated SMS order notifications, right within WordPress! Alpha SMS has a WordPress plugin that allows you to send status updates about the order by sending an SMS to your customers. This plugin is designed for sending bulk SMS messages to your users, creating a marketing channel to get in direct contact with your users.

Download Learn More
wp sms plugin

Laravel SMS Package

Introducing the Alpha SMS Laravel Package – a powerful solution for effortless SMS integration into your Laravel applications. Integrate SMS notifications into your Laravel applications with ease.

Composer Install Learn More
alpha sms laravel package

Question?

If you need help with selecting the right solution for your business, please call us at 09613-250250 within 9:00AM- 9:00PM or you can start a live chat. We are available 24/7 via live chat.

anyquestion