Developer platform

Add reliable messaging to your product

Send transactional SMS through REST, manage API credentials, and diagnose requests without leaving the MainMsg workspace.

POST /api/v1/messages/send
curl -X POST https://api.mainmsg.com/api/v1/messages/send \
  -H "Authorization: Bearer $MAINMSG_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "sms",
    "sender": "APEXRETAIL",
    "body": "Your order has shipped!",
    "recipients": ["255712345678"]
  }'
Developer documentation

Build reliable SMS into your product

A focused REST API for transactional SMS. Create a project, issue a secure API key, and send messages with a predictable request contract.

01

Create a project

Keep each application and environment isolated.

02

Generate a key

Store the bearer token in server-side secrets.

03

Send and monitor

Queue SMS and inspect every request in API logs.

Send SMS

Queue one or more transactional messages.

POST

Endpoint

https://api.mainmsg.com/api/v1/messages/send

cURL
curl --request POST "https://api.mainmsg.com/api/v1/messages/send" \
  --header "Authorization: Bearer $MAINMSG_API_KEY" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --data '{
    "channel": "sms",
    "sender": "APEXRETAIL",
    "body": "Your order has shipped.",
    "recipients": ["255712345678"]
  }'

Bearer authentication

Pass a live API key with every request. Inactive, expired, or revoked keys are rejected.

Authorization: Bearer main_live_…

Delivery prerequisites

  • Approved sender ID
  • Available SMS credits
  • Server-side API key storage

Request contract

Submit a JSON body with Content-Type and Accept set to application/json.

ParameterTypeRequiredDetails
channelstringRequiredUse sms.
senderstringRequiredAn approved sender ID available to your organization (maximum 50 characters).
bodystringConditionalMessage content, up to 5,000 characters. Required unless template_id is provided.
template_idintegerOptionalAn active SMS template ID. Its saved content is used when supplied.
recipientsarrayRequired1–1,000 Tanzanian MSISDNs in 2556XXXXXXXX or 2557XXXXXXXX format.
JSON payload
{
  "channel": "sms",
  "sender": "APEXRETAIL",
  "body": "Your order has shipped.",
  "recipients": ["255712345678"]
}

Successful response

A valid request is accepted for asynchronous delivery and returns HTTP 202.

HTTP 202 response
{
  "success": true,
  "message": "Messages queued for delivery.",
  "data": null
}

Production checklist

Review these before directing live traffic to the API.

  • Use a separate project and key for each integration or environment.
  • Never include credentials in browser or mobile application code.
  • Rotate a compromised key immediately from the API keys area.
  • Use request logs to validate rollout and investigate errors.

Ready to improve how your business communicates?

Create your organization, choose a plan, and start sending reliable messages through campaigns or APIs.