REST API Reference

Complete reference for the TXTLINK REST API. Send SMS messages with simple HTTP requests from any programming language.

Base URL

https://api.txtlink.com/api/v1

Send SMS

Send a single SMS message to a phone number.

POST/api/v1/sms/send

Request Parameters

ParameterTypeRequiredDescription
tostringYesRecipient phone number in E.164 format (e.g., +254712345678)
messagestringYesSMS message content (up to 1600 characters)
senderIdNamestringNoSender ID name (e.g., "TXTLINK"). Uses default if not specified
senderIdstringNoSender ID MongoDB ID (alternative to senderIdName)

Examples

bash
curl -X POST https://api.txtlink.com/api/v1/sms/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+254712345678",
    "message": "Hello from TXTLINK!",
    "senderIdName": "TXTLINK"
  }'

Response

Success Response

json
{
  "success": true,
  "messageId": "507f1f77bcf86cd799439011",
  "segments": 1,
  "totalCredits": 1,
  "totalCostKes": 2.0,
  "newBalance": 99,
  "status": "queued",
  "to": "+254712345678",
  "senderId": "TXTLINK"
}

Error Response

json
{
  "error": "Insufficient SMS credits",
  "errorCode": "INSUFFICIENT_CREDITS"
}

HTTP Status Codes

  • 200 - Success
  • 400 - Bad Request (invalid parameters)
  • 401 - Unauthorized (invalid credentials)
  • 402 - Payment Required (insufficient credits)
  • 403 - Forbidden (sender ID not authorized)
  • 500 - Internal Server Error

Authentication

All API requests require authentication. You can use either API keys (recommended) or username/password. See the Authentication guide for details.

Rate Limits

API rate limits are based on your account tier:

  • Free tier: 100 requests per minute
  • Starter: 500 requests per minute
  • Professional: 2,000 requests per minute
  • Enterprise: Custom limits