All Tutorials Tutorials
Advanced

Developer Guide: Send SMS via the REST API

Integrate SMS sending into your own application using our REST API. Includes code examples in Python, JavaScript, and cURL.

6 min read

Building your own app? Use the SMS Localhost REST API to send messages programmatically. Perfect for transactional SMS, OTP verification, or custom workflows.

Getting Your API Key

  1. Go to API Keys in your dashboard sidebar
  2. Enter a name for the key (e.g. "My App")
  3. Click Create
  4. Copy the key immediately — it's shown only once!
Security: Never share your API key or commit it to version control. Use environment variables in your application.

Send an SMS — Code Examples

cURL
curl -X POST https://sms.localhost.co.zw/api/sms/send/ \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "263771234567",
    "sender": "ACME",
    "message": "Hello from the API!"
  }'
Python
import requests

response = requests.post(
    "https://sms.localhost.co.zw/api/sms/send/",
    headers={"X-API-Key": "your-api-key-here"},
    json={
        "to": "263771234567",
        "sender": "ACME",
        "message": "Hello from the API!",
    }
)
print(response.json())
JavaScript (Node.js)
const response = await fetch(
  "https://sms.localhost.co.zw/api/sms/send/",
  {
    method: "POST",
    headers: {
      "X-API-Key": "your-api-key-here",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      to: "263771234567",
      sender: "ACME",
      message: "Hello from the API!",
    }),
  }
);
const data = await response.json();
console.log(data);

For full API documentation including webhooks, delivery status callbacks, and bulk sending, visit the API Docs page.

Ready to try this yourself?

Sign up for free and start sending branded SMS in minutes.

Get Started Free