Developer guide

SPARKSMS API

Send SMS messages from your application, retrieve your available SMS credits, and list the Sender IDs approved for your account. All endpoints return JSON.

Sign in to generate an API key

Authentication

Create an API key in your signed-in SPARKSMS dashboard. Keep the key secret, send it only over HTTPS, and do not include it in browser-side code or public repositories. Replacing the key immediately invalidates the previous key.

Authorization: Bearer YOUR_SPARKSMS_API_KEY
Accept: application/json
Content-Type: application/json

Send SMS messages

Submit between 1 and 20 unique Tanzanian mobile numbers per request. The Sender ID must be approved on your SPARKSMS account. A message can use up to six SMS segments; credits are reserved before the provider is contacted.

POSThttps://fickledevtech.co.tz/api/v1/messages.php

JSON fields: sender_id (approved Sender ID numeric id), to (phone string or array), and text (message text).

curl --request POST \
  --url 'https://fickledevtech.co.tz/api/v1/messages.php' \
  --header 'Authorization: Bearer YOUR_SPARKSMS_API_KEY' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data-raw '{
    "sender_id": 12,
    "to": ["255712345678", "255765432109"],
    "text": "Your appointment is confirmed."
  }'

Accepted response (HTTP 202):

{
  "data": {
    "status": "accepted",
    "scheduled_for": "2026-10-10 09:15:00",
    "accepted": 2,
    "failed": 0,
    "unknown": 0,
    "results": [
      {
        "to": "255712345678",
        "status": "accepted",
        "provider_message_id": "provider-reference",
        "sms_count": 1
      }
    ]
  }
}
A successful API response confirms provider acceptance, not delivery to the recipient. Use message reports in your SPARKSMS dashboard for delivery status. The API submits messages with a short future send time to satisfy provider scheduling requirements.

Check your SMS balance

Balance is your available SPARKSMS credits. One credit covers one estimated SMS segment.

GEThttps://fickledevtech.co.tz/api/v1/balance.php
curl --request GET \
  --url 'https://fickledevtech.co.tz/api/v1/balance.php' \
  --header 'Authorization: Bearer YOUR_SPARKSMS_API_KEY' \
  --header 'Accept: application/json'
{
  "data": {
    "balance": 250,
    "unit": "SMS segments",
    "account_status": "active"
  }
}

Fetch your approved Sender IDs

Use this list to find the numeric id required by the send SMS endpoint. Only Sender IDs approved for your account are returned.

GEThttps://fickledevtech.co.tz/api/v1/sender-ids.php
curl --request GET \
  --url 'https://fickledevtech.co.tz/api/v1/sender-ids.php' \
  --header 'Authorization: Bearer YOUR_SPARKSMS_API_KEY' \
  --header 'Accept: application/json'
{
  "data": [
    {"id": 12, "sender_id": "YOURBRAND"}
  ]
}

Errors and credit protection

Errors use a JSON error object with a stable code and a human-readable message.

HTTP 402 Payment Required
{
  "error": {
    "code": "insufficient_balance",
    "message": "Your SMS balance is too low. Replenish your credits before sending."
  },
  "balance": 0,
  "required": 2
}

When available credits are less than the estimated segment cost, SPARKSMS rejects the entire send request before contacting the SMS provider. Add credits through your account before sending again. Common HTTP statuses include 400 (invalid JSON), 401 (invalid API key), 402 (insufficient balance), 403 (inactive account), 405 (unsupported method), 413 (body too large), 422 (invalid fields), and 503 (provider unavailable).