How to Send Hashed SMS
This action requires headers to be sent with your API Key. This can be retrieved from your account by accessing the api details section
You can send a single hashed SMS by making a HTTP POST request with the following:
Endpoint
https://service.textpie.co.ke/api/v1/customer/sms/hashed
Request Body
{
"phone": "string",
"api_username": "string",
"campaign_name": "string",
"sender_id": "string",
"message": "string"
}
Code Examples
curl --location 'https://service.textpie.co.ke/api/v1/customer/sms/hashed' \
--header 'X-API-KEY: {API_KEY}' \
--header 'Content-Type: text/plain' \
--data '{
"phone": "0700000000",
"api_username": "{API_USENAME}",
"campaign_name": "15-May-20:45",
"sender_id": "{SENDER_ID}",
"message": "Hello Textpie!"
}'
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\"phone\": \"0700000000\",\"api_username\": \"{API_USERNAME}\",\"campaign_name\": \"15-May-20:45\",\"sender_id\": \"{SENDER_ID}\",\"message\": \"Hello Textpie!\"}");
Request request = new Request.Builder()
.url("https://service.textpie.co.ke/api/v1/customer/sms/hashed")
.method("POST", body)
.addHeader("accept", "application/json")
.addHeader("X-API-KEY", "{API_KEY}")
.addHeader("Content-Type", "text/plain")
.build();
Response response = client.newCall(request).execute();
var http = require('follow-redirects').http;
var fs = require('fs');
var options = {
'method': 'POST',
'hostname': 'service.textpie.co.ke',
'path': '/api/v1/customer/sms/hashed',
'headers': {
'X-API-KEY': '{API_KEY}',
'Content-Type': 'text/plain'
},
'maxRedirects': 20
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = "{\"phone\": \"0700000000\",\"api_username\": \"{API_USERNAME}\",\"campaign_name\": \"14-Jan-08:57\",\"sender_id\": \"{SENDER_ID}\",\"message\": \"Hello Textpie!\"}";
req.write(postData);
req.end();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://service.textpie.co.ke/api/v1/customer/sms/hashed',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"phone": "0700000000",
"api_username": "{API_USERNAME}",
"campaign_name": "15-May-20:45",
"sender_id": "{SENDER_ID}",
"message": "Hello Textpie!"
}',
CURLOPT_HTTPHEADER => array(
'X-API-KEY: {API_KEY}',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://service.textpie.co.ke/api/v1/customer/sms/hashed"
payload = {
"phone": "0700000000",
"api_username": "{API_USERNAME}",
"campaign_name": "15-May-20:45",
"sender_id": "{SENDER_ID}",
"message": "Hello Textpie!"
}
headers = {
'X-API-KEY': '{API_KEY}',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)
require "uri"
require "json"
require "net/http"
url = URI("https://service.textpie.co.ke/api/v1/customer/sms/hashed")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = "{API_KEY}"
request["Content-Type"] = "application/json"
request.body = {
:phone => "0700000000",
:api_username => "{API_USERNAME}"
:campaign_name => "15-May-20:45"
:sender_id => "{SENDER_ID}",
:message => "Hello Textpie!"
}.to_json
response = https.request(request)
puts response.read_body
Payload
Parameter | Description | Required |
---|---|---|
phone | A single phone number (MSISDN) | YES |
api_username | Account username. This can be retrieved from your account's API details menu | YES |
campaign_name | The name of the campain to be sent | YES |
sender_id | Your registered short code or alphanumeric | YES |
message | The message to be sent | YES |
Example of a Successful Response
{
"id": "string",
"phone": "string",
"campaign_name": "string",
"sender_id": "string",
"message": "string"
}
Status codes
Code | Description |
---|---|
201 | SMS message(s) successfully queued |
401 | Authentication error |
402 | Insufficient units |
403 | Invalid sender id |
404 | Account not found |