Skip to main content

POST Send SMS

Betatel's SMS API provides a powerful and reliable way to send messages instantly, ensuring seamless communication with your users. Whether you're sending transactional updates, promotional alerts, or authentication messages, our API is designed for speed, security, and global reach.

In this guide, we’ll focus on one of the most common SMS use cases: sending OTP (One-Time Password) messages. OTPs are essential for user authentication, account verification, and secure transactions, ensuring that only authorized users can access sensitive data or complete actions.

Follow the steps below to integrate and send OTP messages using Betatel’s SMS API with ease. 🚀

Configure the API Endpoint

Start by preparing the endpoint URL for your request.

https://api.betatel.com/api/v1/connect-hub/sms
  • Method: POST

Set Up the Headers

Add the necessary headers for your API request:

ParamValueDescription
Content-typeapplication/jsonSpecifies the payload format.
x-api-key{{x-api-key}}API key for authorization.
x-user-id{{x-user-id}}User identifier for added security and tracking.

Craft the Request Body

Design the JSON payload to include the sender, recipient, and the message content.

Example of body
{"from":"Sender", "to":"12345678548", "text":"Your code is 555345"}
FieldTypeRequiredDescription
fromstringYesThe sender ID or name (e.g., "Sender").
tostringYesThe recipient's phone number in international format.
textstringYesThe message content (e.g., "Your code is 555345").

Code Snippets

Here's how to implement the API call in different programming languages:

Example - cURL
curl --location 'https://api.betatel.com/api/v1/connect-hub/sms' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-user-id: YOUR_USER_ID' \
--data '{
"from":"Sender",
"to":"12345678548",
"text": "Your code is 555345"
}'

Understanding the Response

Once the API processes your request, it returns a response containing a unique identifier for your message.

JSON Schema:

{
"messageId": "0a62face-6d15-11f0-962f-d89d6729654c",
"from": "Sender",
"to": "38161444555"
}
  • messageId: A unique string to track the delivery and status of your message.
  • from: The caller ID displayed to the recipient.
  • to: The recipient's phone number.

Error Handling

  • 400 - Bad Request: Invalid parameters or malformed request
  • 401 - Unauthorized: Authentication failed
  • 500 - Internal Server Error: An unexpected error occurred on the server