Sending a Message
To send a message, replace the following variables in the examples below:
| Key | Description |
|---|---|
| SENDLIME_API_KEY | Your SendLime API key starting with sl_live_ (create one on your dashboard). |
| TO_NUMBER | The phone number you are sending the message to (E.164 format). |
| BRAND_ID | (Optional) Your approved SMS sender or WhatsApp profile. If omitted, the default sender/profile is used. |
- cURL
- Node.js
- Python
- PHP / Laravel
- Java
- C# / .NET
- Go
- Ruby
info
All API requests are authenticated using a Bearer token in the Authorization header.
Send an SMS
curl -X POST "https://api.sendlime.com/api/v2/messages" \
-H "Authorization: Bearer $SENDLIME_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "'$TO_NUMBER'",
"message": "A text message sent using the SendLime API",
"channel": "sms",
"brand_id": "'$BRAND_ID'"
}'
Send a WhatsApp message
curl -X POST "https://api.sendlime.com/api/v2/messages" \
-H "Authorization: Bearer $SENDLIME_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "'$TO_NUMBER'",
"message": "A WhatsApp message sent using the SendLime API",
"channel": "whatsapp"
}'
Check your balance
curl "https://api.sendlime.com/api/v2/balance" \
-H "Authorization: Bearer $SENDLIME_API_KEY"
Fetch message logs
curl "https://api.sendlime.com/api/v2/messages?limit=10" \
-H "Authorization: Bearer $SENDLIME_API_KEY"
Send an SMS
const SENDLIME_API_KEY = "sl_live_your_key_here";
const response = await fetch("https://api.sendlime.com/api/v2/messages", {
method: "POST",
headers: {
"Authorization": `Bearer ${SENDLIME_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
to: "8801XXXXXXXXX",
message: "A text message sent using the SendLime API",
channel: "sms",
brand_id: "YourBrandName",
}),
});
const data = await response.json();
if (data.success) {
console.log("Message sent!", data.data.gateway_id);
console.log("Credits remaining:", data.data.credits_remaining);
} else {
console.error("Failed:", data.error);
}
Send a WhatsApp message
const response = await fetch("https://api.sendlime.com/api/v2/messages", {
method: "POST",
headers: {
"Authorization": `Bearer ${SENDLIME_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
to: "8801XXXXXXXXX",
message: "Hello via WhatsApp!",
channel: "whatsapp",
}),
});
const data = await response.json();
console.log(data);
Check your balance
const response = await fetch("https://api.sendlime.com/api/v2/balance", {
headers: { "Authorization": `Bearer ${SENDLIME_API_KEY}` },
});
const { data } = await response.json();
console.log(`Balance: ${data.balance} ${data.currency}`);
Send an SMS
import requests
API_KEY = "sl_live_your_key_here"
BASE_URL = "https://api.sendlime.com/api/v2"
response = requests.post(
f"{BASE_URL}/messages",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"to": "8801XXXXXXXXX",
"message": "A text message sent using the SendLime API",
"channel": "sms",
"brand_id": "YourBrandName",
},
)
data = response.json()
if data.get("success"):
print("Message sent!", data["data"]["gateway_id"])
print("Credits remaining:", data["data"]["credits_remaining"])
else:
print("Failed:", data.get("error"))
Send a WhatsApp message
response = requests.post(
f"{BASE_URL}/messages",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"to": "8801XXXXXXXXX",
"message": "Hello via WhatsApp!",
"channel": "whatsapp",
},
)
print(response.json())
Check your balance
response = requests.get(
f"{BASE_URL}/balance",
headers={"Authorization": f"Bearer {API_KEY}"},
)
data = response.json()["data"]
print(f"Balance: {data['balance']} {data['currency']}")
Send an SMS
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.sendlime.com/api/v2/messages', [
'headers' => [
'Authorization' => 'Bearer ' . $apiKey,
'Content-Type' => 'application/json',
],
'json' => [
'to' => '8801XXXXXXXXX',
'message' => 'A text message sent using the SendLime API',
'channel' => 'sms',
'brand_id' => 'YourBrandName',
],
]);
$data = json_decode($response->getBody(), true);
if ($data['success']) {
echo 'Message sent! Gateway ID: ' . $data['data']['gateway_id'];
echo 'Credits remaining: ' . $data['data']['credits_remaining'];
} else {
echo 'Failed: ' . $data['error'];
}
Send a WhatsApp message
$response = $client->request('POST', 'https://api.sendlime.com/api/v2/messages', [
'headers' => [
'Authorization' => 'Bearer ' . $apiKey,
'Content-Type' => 'application/json',
],
'json' => [
'to' => '8801XXXXXXXXX',
'message' => 'Hello via WhatsApp!',
'channel' => 'whatsapp',
],
]);
print_r(json_decode($response->getBody(), true));
Check your balance
$response = $client->request('GET', 'https://api.sendlime.com/api/v2/balance', [
'headers' => [
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$data = json_decode($response->getBody(), true)['data'];
echo "Balance: {$data['balance']} {$data['currency']}";
Send an SMS
import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """
{
"to": "8801XXXXXXXXX",
"message": "A text message sent using the SendLime API",
"channel": "sms",
"brand_id": "YourBrandName"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.sendlime.com/api/v2/messages"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Send a WhatsApp message
String json = """
{
"to": "8801XXXXXXXXX",
"message": "Hello via WhatsApp!",
"channel": "whatsapp"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.sendlime.com/api/v2/messages"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Check your balance
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.sendlime.com/api/v2/balance"))
.header("Authorization", "Bearer " + apiKey)
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Send an SMS
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var payload = new
{
to = "8801XXXXXXXXX",
message = "A text message sent using the SendLime API",
channel = "sms",
brand_id = "YourBrandName"
};
var content = new StringContent(
System.Text.Json.JsonSerializer.Serialize(payload),
System.Text.Encoding.UTF8,
"application/json"
);
var response = await client.PostAsync("https://api.sendlime.com/api/v2/messages", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
Send a WhatsApp message
var payload = new
{
to = "8801XXXXXXXXX",
message = "Hello via WhatsApp!",
channel = "whatsapp"
};
var content = new StringContent(
System.Text.Json.JsonSerializer.Serialize(payload),
System.Text.Encoding.UTF8,
"application/json"
);
var response = await client.PostAsync("https://api.sendlime.com/api/v2/messages", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Check your balance
var response = await client.GetAsync("https://api.sendlime.com/api/v2/balance");
Console.WriteLine(await response.Content.ReadAsStringAsync());
Send an SMS
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"io"
)
func main() {
apiKey := "sl_live_your_key_here"
payload, _ := json.Marshal(map[string]string{
"to": "8801XXXXXXXXX",
"message": "A text message sent using the SendLime API",
"channel": "sms",
"brand_id": "YourBrandName",
})
req, _ := http.NewRequest("POST", "https://api.sendlime.com/api/v2/messages", bytes.NewBuffer(payload))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Send a WhatsApp message
payload, _ := json.Marshal(map[string]string{
"to": "8801XXXXXXXXX",
"message": "Hello via WhatsApp!",
"channel": "whatsapp",
})
req, _ := http.NewRequest("POST", "https://api.sendlime.com/api/v2/messages", bytes.NewBuffer(payload))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
Check your balance
req, _ := http.NewRequest("GET", "https://api.sendlime.com/api/v2/balance", nil)
req.Header.Set("Authorization", "Bearer "+apiKey)
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
Send an SMS
require 'net/http'
require 'json'
require 'uri'
api_key = "sl_live_your_key_here"
uri = URI("https://api.sendlime.com/api/v2/messages")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request.body = {
to: "8801XXXXXXXXX",
message: "A text message sent using the SendLime API",
channel: "sms",
brand_id: "YourBrandName"
}.to_json
response = http.request(request)
data = JSON.parse(response.body)
if data["success"]
puts "Message sent! Gateway ID: #{data['data']['gateway_id']}"
puts "Credits remaining: #{data['data']['credits_remaining']}"
else
puts "Failed: #{data['error']}"
end
Send a WhatsApp message
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request.body = {
to: "8801XXXXXXXXX",
message: "Hello via WhatsApp!",
channel: "whatsapp"
}.to_json
response = http.request(request)
puts JSON.parse(response.body)
Check your balance
uri = URI("https://api.sendlime.com/api/v2/balance")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer #{api_key}"
response = http.request(request)
data = JSON.parse(response.body)["data"]
puts "Balance: #{data['balance']} #{data['currency']}"
Try it out
When you run the example above, the message will be sent to the phone number that you specified.
caution
As per the BTRC guidelines, promotional messages have to be in Bangla.