Send SMS (Single)

POST /SMS/Single/

This endpoint is used to send a single SMS to a single recipient. The SMS can be sent immediately or can be scheduled for delivery at a later date and time.

Usage scenario for this endpoint:

This endpoint is especially useful for sending recipient-specific one-time alert messages or updates, such as OTPs or transaction updates, etc.

Method Details
HTTP Method POST
Content type Application/json
Requires authentication? YES
Rate limited? YES
Headers User-Agent
Module SMS
End Point

https://apisms.mainbrainer.com/sms/single

Required Parameters Usage Description
Access Token or API Key Authorization: Bearer {token} header Pass the API key in the request header for request authentication. Read more about our authentication process.
Sender Name Used in the request body In case you wish to use a custom sender name for your SMS sending, write to us at [email protected] to create and verify a custom sender name.
Body Used in the request body This parameter includes the complete text of the SMS you wish to send.
Recipient Used in the request body This parameter specifies the mobile number to which you want to send an SMS.
Also, ensure that you prefix the country code to the mobile number. For example, when sending messages to a mobile number in Norway, the to parameter value should look like – 4793454496, where 47 is the country code for Norway, and 93454496 is the intended recipient mobile number.
Note

In case the message body is more than 160 GSM-7 characters long (or more than unicode 70 UCS-2 characters), your messages will be split into multiple 160-character messages and concatenated, resulting in separately billed messages.Read more about SMS encoding on MainBrainer.

Note

You’ll need to create and verify a sender name before you can use it to send SMSs. If you don’t wish to create a custom sender name, you can use MainBrainer as the sender name for your SMS sendings.

Note

MainBrainer supports Alphanumeric Sender IDs for use as Sender Names. Kindly ensure that you use a sender name compliant with the rules and regulations of the country where you wish to send the SMSs.

Note

The scheduled date and time of the message should be specified in the RFC3339 format (Y-m-d\TH:i:sP).

Optional Parameters Usage Description
Body Encrypted Isbodyencrypted = boolean and default = false Pass the parameter value as Isbodyencrypted if you wish to encrypt your message body. Doing so helps you encrypt important information like password and other Secure details that might be a part of the message body.
Personalization Substitution Tags tagName = string, tagValue = string These tags help you insert dynamic data at the time of SMS sending. In order to substitute the data at the time of the sending, follow the pattern tagName:tagValue to substitute for the key/value pairs.
Scheduled Date-time RFC3339 format (Y-m-d\TH:i:sP) Pass the scheduled date and time of the message in RFC3339 format (Y-m-d\TH:i:sP). The date and time passed in this parameter will be converted as per the offset value specified in your account settings.
Landing Page ID landingpageid (uuid) eg: "3fa85f64-5717-4562-b3fc-2c963f66afa6 Landingpageid is the unique identifier for a landing page created in your MainBrainer account. In case you wish to include a landing page in your SMS Sending, pass the landing page ID as the parameter value.
Unique URL Isuniqueurl = boolean and default = true In case you wish to monitor recipient-specific analytics for the SMS sending, send the landing page as a unique URL.
Shortner URL shortnerUrl = string, default = sms.club In case you wish to use a custom shortener for your landing page, specify the same here. Otherwise, we’ll use the default shortener sms.club
Webhook URL Delivery Status Use this parameter to specify the webhook URL where you want to receive delivery status updates for the SMS being sent. When the SMS operator returns a delivery status, the status is instantly posted to this webhook URL. Using a Webhook enables your application to receive delivery updates as they happen, in an easily parsable JSON format.
Updates will be sent for the following delivery statuses:
+ Submitted
+ Processed
+ Delivered
+ Failed

Landing Page and Landing page ID

Every Landing Page on MainBrainer is assigned a Landing Page ID that acts as a unique identifier or the landing page. To read more about creating landing pages on MainBrainer,refer to our detailed article series.

Response

In case there is a problem with the data in the request body, or if there are no properties included in the request, we'll return a 400 and 422 response along with additional details listing the cause.

Copy
Copied

This example demonstrates how to send a single SMS. 
post url: https://apisms.mainbrainer.com/sms/single


{
"recipient": 4790812501,
"senderName": "MainBrainer",
"isBodyEncrypted": false,   
"body": "Hi [firstname], test SMS from MainBrainer.",
"personalizationSubstitutionTags": [
  {
    "tagName": "[firstname]",
    "tagValue": "Tom"
  }
],
"scheduleDateTime": "2021-03-11T11:43:55.759Z",
"landingPageId": "00000000-0000-0000-0000-000000000000",
"shortner": {
  "shortnerUrl": "sms.club",
  "isUniqueUrl": true
},
"webHookUrl" : "https://webhook-url.yourdomain.com"
}



Returns a 202 Accepted response with content on success.
    

Response Body

Copy
Copied
    "status": "Success",
    "message": "Successfully accepted.",
    "data": {
        "QueueId": "36032bdc-1716-4205-9c10-69a61c17909e",
        "QueuedTimestamp": 1631601011202
    }
}