SEND SMS


Introduction

Our SMS API empowers you to craft customer journeys through interactive conversations seamlessly integrated within your application environment.

Endpoint

This endpoint allows users to send a single SMS message.

Method Endpoint
POST https://app.techspace.co.ke/api/v1/single-sms

Headers

Header Description Value
api-key The API key provided to authenticate the user. szrgh88Z62Ne828RcXM1sCRbFEfm42St
client-id The client ID associated with the user's API key. F2ikqLLEA9EsmWyTzeEAsjln0avMxTix

Note: These are example values. Please obtain your actual API key and client ID from the portal. Visit the portal, go to Settings, then API Keys, and generate your keys.

Request Body

Raw JSON

{
    "senderId": "Techspace",
    "message": "This is a test message.",
    "mobileNumber": "0706528249"
}

Response

Success

{
    "success": true,
    "message": "SMS sent successfully",
    "data": {
        "ErrorCode": 0,
        "ErrorDescription": null,
        "Data": [
            {
                "MessageErrorCode": 0,
                "MessageErrorDescription": "Success",
                "MobileNumber": "254706528249",
                "MessageId": "f784f6de-a71c-4265-b66b-3d1652cc828c",
                "Custom": null
            }
        ]
    }
}

Examples

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://app.techspace.co.ke/api/v1/single-sms',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "senderId": "Techspace",
    "message": "This is a test message.",
    "mobileNumber": "0706528249"   
}
',
  CURLOPT_HTTPHEADER => array(
    'api-key: szrgh88Z62Ne828RcXM1sCRbFEfm42St',
    'client-id: F2ikqLLEA9EsmWyTzeEAsjln0avMxTix'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>

Node JS

var axios = require('axios');
var data = '{\n    "senderId": "Techspace",\n    "message": "This is a test message.",\n    "mobileNumber": "0706528249"   \n}\n';

var config = {
  method: 'post',
maxBodyLength: Infinity,
  url: 'https://app.techspace.co.ke/api/v1/single-sms',
  headers: { 
    'api-key': 'szrgh88Z62Ne828RcXM1sCRbFEfm42St', 
    'client-id': 'F2ikqLLEA9EsmWyTzeEAsjln0avMxTix'
  },
  data : data
};

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

Curl


curl --location 'https://app.techspace.co.ke/api/v1/single-sms' \
--header 'api-key: szrgh88Z62Ne828RcXM1sCRbFEfm42St' \
--header 'client-id: F2ikqLLEA9EsmWyTzeEAsjln0avMxTix' \
--data '{
    "senderId": "Techspace",
    "message": "This is a test message.",
    "mobileNumber": "0706528249"   
}
'

Javascript

var myHeaders = new Headers();
myHeaders.append("api-key", "szrgh88Z62Ne828RcXM1sCRbFEfm42St");
myHeaders.append("client-id", "F2ikqLLEA9EsmWyTzeEAsjln0avMxTix");

var raw = "{\n    \"senderId\": \"Techspace\",\n    \"message\": \"This is a test message.\",\n    \"mobileNumber\": \"0706528249\"   \n}\n";

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://app.techspace.co.ke/api/v1/single-sms", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Python

import http.client

conn = http.client.HTTPSConnection("app.techspace.co.ke")
payload = "{\n    \"senderId\": \"Techspace\",\n    \"message\": \"This is a test message.\",\n    \"mobileNumber\": \"0706528249\"   \n}\n"
headers = {
  'api-key': 'szrgh88Z62Ne828RcXM1sCRbFEfm42St',
  'client-id': 'F2ikqLLEA9EsmWyTzeEAsjln0avMxTix'
}
conn.request("POST", "/api/v1/single-sms", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Go Native

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://app.techspace.co.ke/api/v1/single-sms"
  method := "POST"

  payload := strings.NewReader(`{
    "senderId": "Techspace",
    "message": "This is a test message.",
    "mobileNumber": "0706528249"   
}
`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("api-key", "szrgh88Z62Ne828RcXM1sCRbFEfm42St")
  req.Header.Add("client-id", "F2ikqLLEA9EsmWyTzeEAsjln0avMxTix")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}