API Reference

Base URL: https://www.smsforai.com/api/v1

Authentication

All authenticated endpoints require a Bearer token in the Authorization header.

Authorization: Bearer smsai_<your-token>
GET /api/v1 Public

API Info

Returns API version, status, and available endpoints.

Response

{ "api": "SMS for AI", "version": "1.0", "status": "ok" }
GET /api/v1/me 🔑 Auth required

Token Info

Get details about the current API token and authenticated user.

Response

{
  "token": { "id": 1, "name": "My Agent", "permissions": ["sms:send"] },
  "user": { "name": "Alice", "email": "alice@example.com", "credits": 12.345678 }
}
GET /api/v1/balance 🔑 Auth required

Account Balance

Get the current credit balance of the authenticated account.

Response

{ "credits_usd": 12.345678 }
GET /api/v1/countries 🔑 Auth required

Country Prices

Get a list of all active countries and their per-SMS prices in USD.

Response

[
  { "country_code": "US", "country_name": "United States", "dial_code": "+1", "price_usd": 0.01 },
  ...
]
POST /api/v1/sms/send 🔑 Auth required

Send SMS

Send an SMS message. Your token must have the 'sms:send' permission.

Request Body

{
  "to": "+12025551234",       // E.164 format, required
  "body": "Hello!",          // message text, max 1600 chars
  "sender_id": "MyApp",      // optional alphanumeric sender ID
  "include_conversion_url": true  // optional: append a tracking pixel URL
}

Response

{
  "id": 42,
  "status": "sent",
  "to": "+12025551234",
  "price_usd": 0.01,
  "nvia_message_id": "abc123",
  "conversion_url": "https://yourdomain.com/c/TOKEN"
}
GET /api/v1/sms 🔑 Auth required

List SMS

List sent messages. Supports ?status=sent|delivered|failed and pagination.

Response

{ "data": [...], "links": { ... }, "meta": { ... } }
GET /api/v1/sms/{id} 🔑 Auth required

Get SMS

Get a specific SMS by ID.

Response

{ "id": 42, "status": "delivered", "to": "+12025551234", ... }
POST /api/v1/conversion/report 🔑 Auth required

Report Conversion

Programmatically report a conversion for an SMS. The sms_id must belong to your account.

Request Body

{
  "sms_id": 42,
  "metadata": { "page": "/checkout", "value": 49.00 }  // optional
}

Response

{ "message": "Conversion recorded.", "sms_id": 42 }

Error Codes

HTTP Meaning
401 Missing or invalid Bearer token
403 Token lacks the required permission, IP not whitelisted, or spending limit reached
402 Insufficient credits to send SMS
422 Validation error — check request body
429 Rate limit exceeded (per-minute or per-day)
500 Internal server error or SMS gateway failure

Code Example (Python)

import requests

TOKEN = "smsai_YourTokenHere"
BASE  = "https://www.smsforai.com/api/v1"

resp = requests.post(
    f"{BASE}/sms/send",
    headers={"Authorization": f"Bearer {TOKEN}", "Accept": "application/json"},
    json={
        "to": "+12025551234",
        "body": "Your OTP is 482910. Reply STOP to opt out.",
        "include_conversion_url": True
    }
)
data = resp.json()
print(data["status"], data.get("conversion_url"))