Sending Your First SMS with the Unifonic API

Send an SMS by making a REST API request. Before you begin, obtain a Unifonic account, an application ID (AppSid), and a registered Sender ID.

Send the request

Send an HTTP POST request to https://el.cloud.unifonic.com/rest/SMS/messages.

Request parameters

ParameterDescriptionExample
AppSidAuthentication string that uniquely identifies the application.6v253153sxxxxxxxx
SenderIDSender ID displayed to the recipient. If omitted, the system uses the default Sender ID.Sender
RecipientDestination number in international format without 00 or +.96650598XXXX
BodyMessage content. Supports English and Unicode characters, including Arabic.Hello world!
responseTypeResponse format. Only JSON is supported.JSON
CorrelationIDUnique identifier attached to the request and message.CorrelationID
baseEncodeIndicates whether binary data is represented in an ASCII string format.true
asyncIndicates whether the request is executed asynchronously.false

Request examples

cURL form-encoded request
curl --location --request POST 'https://el.cloud.unifonic.com/rest/SMS/messages' 
--header 'Accept: application/json' 
--header 'Content-Type: application/x-www-form-urlencoded' 
--data-urlencode 'AppSid=axuN0U7QlmqVPsfdgoK0mZxxxxxxxx' 
--data-urlencode 'SenderID=UNISMS' 
--data-urlencode 'Body=Hello there' 
--data-urlencode 'Recipient=96650767XXXX' 
--data-urlencode 'responseType=JSON' 
--data-urlencode 'CorrelationID=CorrelationID' 
--data-urlencode 'baseEncode=true' 
--data-urlencode 'async=false'
cURL request with query parameters
curl --location --request POST 'https://el.cloud.unifonic.com/rest/SMS/messages?AppSid=axuN0U7QlmqVPsfdgoK0mZxxxxxxxx&SenderID=UNISMS&Body=Test message&Recipient=971507679351&responseType=JSON&CorrelationID=q1&baseEncode=true&statusCallback=sent&async=false&MessageType=6' 
--header 'Accept: application/json'

Responses

200 OK
{
  "success": true,
  "message": "",
  "errorCode": "ER-00",
  "data": {
    "MessageID": 42000348806924,
    "CorrelationID": "CorrelationID",
    "Status": "Sent",
    "NumberOfUnits": 0,
    "Cost": 0,
    "Balance": 0,
    "Recipient": "971507679351",
    "TimeCreated": "2022-09-06 14:06:25.979",
    "CurrencyCode": ""
  }
}
400 Bad Request
{
  "success": false,
  "message": "Dest num is too short",
  "errorCode": "ER-04",
  "data": {}
}

Status codes

CodeDescription
200Success
400No rules matched
401Authentication failed
402Missing AppSid parameter
403Invalid IP address
404Incompatible API version
406Wrong parameter format
409Duplicate message
410Invalid recipient format
412Message body is too long
415Invalid hexadecimal string
417Wrong body format
419Wrong date format in request
420Page limit exceeded
421No message body specified
422No recipient parameter specified
423Required timeScheduled parameter not provided
429Too many requests generated by this user
431MessageId is empty
432MessageId must be numeric
440Wrong sender format
449Message body is empty
450Too many destination numbers provided
451TimeScheduled must indicate a future time
452Specify either messageId or recipient
455Scheduled message not found for this user
456Wrong correlationId format
459Authentication parameters are incorrectly Base64-encoded
460Invalid encoding; use UCS2 or GSM7
480User cannot use the specified SenderID
481Country does not exist
482Invalid destination number
483Operator not found
499Error in the configuration request
546Incompatible external data type in configuration
548Wrong dictionary configuration for response parameter
599Request failed