Welcome to TECHWAVE VERIFY SMS API

Our API makes sending and verifying SMS messages as easy as sending a smile. Letโ€™s get started! ๐Ÿ˜Š

Start by creating an account and generating your API encryption key. We offer four products โ€” the first three are OTP-based services, while the fourth is for ordinary SMS communication.

Product Type Description Registration Requirement
Test OTP (Live) Sends live SMS only to your registered number โ€” ideal for testing and development. Basic account
Team OTP (Live) Sends live SMS to anyone who has given consent. Consent can be automated for bulk users or manual for small teams. Requires easy form of registration
Live OTP (Live) Can send SMS to anyone, but requires a higher level of registration and verification. Requires full registration
Standard SMS Non-OTP Enables sending ordinary SMS messages that are not one-time passwords. This product is created separately from the OTP services. Click here to contact sales

Send SMS Code

Authenticate using your API key in the Authorization header. Below is a sample request that demonstrates how to encrypt sensitive data before sending it to the API endpoint.

๐Ÿง  cURL Example (Universal)


curl -X POST https://techwavelinks.co.ke/sms/takeaction.php \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
  "classA": {
    "email": "example@domain.com",
    "project": "my_project"
  },
  "classB": "ENCRYPTED: {
      phone: +254700000000,
      code: A1B-2C3,
      hash: unique_hash_value,
      label: verification project,
      callback_url: https://yourwebsite.com/callback,
      fuzz: [random 30-character string]
  }"
}'
  

๐Ÿ›ก๏ธ Note: The classB field is fully AES-256 encrypted using your private API key. It contains the following parameters before encryption:

Field Description
phoneThe recipient phone number in international format (e.g., +2547XXXXXXX).
codeThe verification code sent to the user (alphanumeric format supported).
hashA unique hash or token generated by your system for verification tracking.
labelA human-readable label describing the purpose of the verification.
callback_urlOptional endpoint that receives delivery or verification status updates.
fuzzA randomly generated 30-character string for uniqueness and tracking. It masks the encryption by making it unpredictable.

๐Ÿ˜ PHP Example


<?php
// ==== CONFIG ====
$endpoint = "https://techwavelinks.co.ke/sms/takeaction.php"; 
$key = "YOUR_API_ENCRYPTION_KEY"; // ๐Ÿ”‘ Keep private and secure

// ==== Generate Random String ====
function randomString($length = 30) {
    $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{};:,<.>/?';
    $str = '';
    $maxIndex = strlen($chars) - 1;
    for ($i = 0; $i < $length; $i++) {
        $str .= $chars[random_int(0, $maxIndex)];
    }
    return $str;
}

$random30 = randomString(30);

// ==== Data ====
$classA = [
    "email"   => "example@domain.com",
    "project" => "my_project"
];

$classB = [
    "phone"        => "+254700000000",
    "code"         => "A1B-2C3",
    "hash"         => "unique_hash_value",
    "label"        => "verification project",
    "callback_url" => "https://yourwebsite.com/callback",
    "fuzz"         => $random30
];

// ==== Encryption ====
function encryptData($data, $key) {
    $iv = random_bytes(16);
    $ciphertext = openssl_encrypt(json_encode($data), "AES-256-CBC", $key, 0, $iv);
    return base64_encode($iv . $ciphertext);
}

$encryptedB = encryptData($classB, $key);

// ==== Payload ====
$payload = [
    "classA" => $classA,
    "classB" => $encryptedB
];

// ==== Send via cURL ====
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

echo "Server Response: $response\n";
?>
  

Verify Sent SMS API

This API is used to verify that a sent SMS was delivered and logged correctly. It checks the phone number, code, and associated database ID. If the verification succeeds, the server confirms delivery.

๐Ÿงพ Request Overview

Endpoint: https://techwavelinks.co.ke/sms/takesent.php

Method: POST

Content-Type: application/json

Authorization: Bearer YOUR_API_KEY

๐Ÿ“ฆ Example Request (cURL)


curl -X POST https://techwavelinks.co.ke/sms/takesent.php \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
  "classA": {
    "email": "example@domain.com",
    "project": "team_project"
  },
  "classB": "ENCRYPTED: {
      phone: +254700000000,
      type: verify,
      code: 123456,
      device: android,
      label: sent verification,
      callback_url: https://yourwebsite.com/callback,
      fuzz: [random 30-character string],
      db_id: 34
  }"
}'
  

๐Ÿ›ก๏ธ Note: The classB field is fully AES-256 encrypted using your private API key. Before encryption, the fields are:

Field Description
phoneRecipient phone number in international format.
typeMust be verify to indicate SMS verification.
codeThe code that was sent to the recipient.
deviceDevice type used by the recipient (e.g., android, ios).
labelDescription of the verification purpose (e.g., "sent verification").
callback_urlOptional endpoint to receive updates or confirmation.
fuzzA randomly generated 30-character string for uniqueness and tracking. It masks the encryption by making it unpredictable.
db_idThe ID of the SMS record in the database for verification.

๐Ÿ˜ PHP Example


<?php
$endpoint = "https://techwavelinks.co.ke/sms/takesent.php";
$key = "YOUR_API_ENCRYPTION_KEY";

function randomString($length = 30) {
    $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{};:,<.>/?';
    $str = '';
    for ($i = 0; $i < $length; $i++) {
        $str .= $chars[random_int(0, strlen($chars) - 1)];
    }
    return $str;
}

$random30 = randomString(30);

$classA = [
    "email" => "example@domain.com",
    "project" => "team_project"
];

$classB = [
    "phone" => "+254700000000",
    "type" => "verify",
    "code" => "123456",
    "device" => "android",
    "label" => "sent verification",
    "callback_url" => "https://yourwebsite.com/callback",
    "fuzz" => $random30,
    "db_id" => 34
];

function encryptData($data, $key) {
    $iv = random_bytes(16);
    $ciphertext = openssl_encrypt(json_encode($data), "AES-256-CBC", $key, 0, $iv);
    return base64_encode($iv . $ciphertext);
}

$encryptedB = encryptData($classB, $key);

$payload = [
    "classA" => $classA,
    "classB" => $encryptedB
];

$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

echo "Server Response: $response\n";
?>
    

๐Ÿ“ก SMS Callback Notification API

Once an SMS is successfully sent, the system automatically sends a callback request to the clientโ€™s specified callback_url. This allows real-time confirmation that the SMS was delivered and logged correctly on the clientโ€™s end.

๐Ÿงพ Callback Overview

Triggered by: System after SMS is sent

Method: POST

Content-Type: application/json

Delivery Guarantee: Retries up to 3 times if client server does not respond with 200 OK.

๐Ÿ“ฆ Example Callback Payload

{
  "status": "sent",
  "timestamp": "2025-10-16T14:35:42Z",
  "db_id": 34,
  "phone": "+254700000000",
  "code": "123456",
  "type": "verify",
  "device": "android",
  "label": "sent verification",
  "fuzz": "3LkP9xZvQwHn2eTy7aD6uS1bR0pC4mX",
  "meta": {
      "project": "team_project",
      "sender": "techwavelinks"
  }
}

โœ… Expected Response (Client)

{
  "received": true,
  "message": "Callback logged successfully"
}

๐Ÿ˜ PHP Example (Client Side Receiver)


<?php
// callback.php - Example endpoint to receive callback

header('Content-Type: application/json');

// Read JSON input
$input = file_get_contents('php://input');
$data = json_decode($input, true);

// Verify required fields
if (isset($data['status'], $data['db_id'], $data['phone'])) {
    // Example: Log callback into database or file
    file_put_contents('callback_log.txt', date('c') . " - " . json_encode($data) . PHP_EOL, FILE_APPEND);

    // Respond with success
    echo json_encode(["received" => true, "message" => "Callback logged successfully"]);
} else {
    // Respond with error
    http_response_code(400);
    echo json_encode(["received" => false, "message" => "Invalid callback data"]);
}
?>
    

๐Ÿง  Notes

Error Codes

Below are the possible error codes returned by the API, categorized by type of request.

๐Ÿ”‘ Authentication Errors

Code Description Action
401 Unauthorized โ€“ Invalid or missing API key. Check your API key and ensure it is sent in the Authorization header.
403 Forbidden โ€“ API key does not have access to this endpoint. Verify API key permissions or upgrade your account.

โš ๏ธ Validation / Request Errors

Code Description Action
400 Bad Request โ€“ Invalid JSON or missing required fields. Check the request payload and ensure all required parameters are provided.
422 Unprocessable Entity โ€“ Data validation failed. Ensure the format and values of parameters match the API specification.

๐Ÿ’ป Server / Internal Errors

Code Description Action
500 Internal Server Error โ€“ Something went wrong on the server. Retry the request later. Contact support if the issue persists.
503 Service Unavailable โ€“ Server is temporarily overloaded or down for maintenance. Try again after some time.

๐Ÿ’ก Tip: Always handle errors gracefully in your app by checking the response code before processing data.