API v1.0

API Documentation

Integrate powerful bulk SMS capabilities into your applications with our simple, RESTful API. Send messages, track delivery, and manage your account programmatically.

Base URL: https://sms.macrasms.com/api/v1/

Important: This is a single-endpoint API. All SMS sending requests go to the same URL: /api/v1/.

1. Overview

This API allows you to send single or bulk SMS messages using your Macra SMS account. Authentication is done via sender_id and api_key passed in the JSON body.

2. Send SMS Endpoint

POST https://sms.macrasms.com/api/v1/

Request Headers

Request Body (JSON)

Field Type Required Description Example
sender_id string Yes Your approved Sender ID "MACRASMS"
api_key string Yes Your API key from the dashboard "6bd654a1ed437c7d0d60a48c2d3b4911de..."
message_text string Yes The message content (max 1600 characters) "Your order #123 has shipped!"
recipients string Yes Comma-separated phone numbers (will be normalized to +254... format) "+254712345678,0712345678,254723456789"
scheduled_at string No Optional scheduled time (MySQL format: YYYY-MM-DD HH:MM:SS) "2026-03-01 14:30:00"

Example Request Body

{
  "sender_id": "MACRASMS",
  "api_key": "6bd654a1ed437c7d0d60a48c2d3b4911de685cfad68aff35a531b3f7491835fa",
  "message_text": "Hello! Your verification code is 48291.",
  "recipients": "+254712345678,0712345678",
  "scheduled_at": "2026-02-15 10:00:00"
}

3. Response Format

The API always returns HTTP 200 OK with JSON content.

Success Response

HTTP 200 - Success
{
  "success": true,
  "message_ids": [1456, 1457],
  "credits_used": 2,
  "recipients_count": 2,
  "new_balance": 1247,
  "message_length": 68,
  "credits_per_message": 1,
  "transaction_id": 8923
}

Error Response

HTTP 200 - Error
{
  "success": false,
  "error": "Invalid sender_id or api_key"
}

Common Error Messages

4. Limits & Rules

5. Sample Code – Sending SMS

PHP (cURL)

<?php
$payload = [
    'sender_id'     => 'MACRASMS',
    'api_key'       => 'your-api-key-here',
    'message_text'  => 'Test message from PHP',
    'recipients'    => '+254712345678,0712345678'
];

$ch = curl_init('https://sms.macrasms.com/api/v1/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));

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

$data = json_decode($response, true);

if ($data['success'] ?? false) {
    echo "Success! Sent to {$data['recipients_count']} recipients.\n";
} else {
    echo "Error: " . ($data['error'] ?? 'Unknown') . "\n";
}
?>

Python (requests)

import requests

payload = {
    "sender_id": "MACRASMS",
    "api_key": "your-api-key-here",
    "message_text": "Hello from Python!",
    "recipients": "+254712345678,0712345678"
}

response = requests.post(
    "https://sms.macrasms.com/api/v1/",
    json=payload
)

data = response.json()

if data.get("success"):
    print(f"Success → {data['recipients_count']} sent")
else:
    print(f"Failed: {data.get('error')}")

JavaScript (fetch)

const payload = {
  sender_id: "MACRASMS",
  api_key: "your-api-key-here",
  message_text: "Test from JS",
  recipients: "+254712345678,+254723456789"
};

fetch("https://sms.macrasms.com/api/v1/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload)
})
  .then(res => res.json())
  .then(data => {
    if (data.success) {
      console.log(`Sent to ${data.recipients_count} numbers`);
    } else {
      console.error("Error:", data.error);
    }
  })
  .catch(err => console.error(err));
Support: For issues, contact your Macra SMS account support or check the dashboard for your API key and sender IDs.
Need Help? Contact Support