OMNI: Send simple message

This method allows you to send a single message to one or more destination addresses over the OMNI channel.

Resource

https://api.infobip.com/omni/1/text

Parameters

Property name Type Description
phoneNumber* string Destination phone number. Phone numbers must be in international format (example: 41793026727).
emailAddress string Destination email address.
messageId string The ID that uniquely identifies the message sent.
bulkId string The ID which uniquely identifies the request. Bulk ID will be received only when you send a message to more than one destination address.
scenarioKey string Scenario key that uniquely identifies the scenario which will be used when sending message.
text string Text of the message that will be sent.
mailSubject string Email subject

Request Example

					POST /omni/1/text HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json

{ 
    "destinations":[ 
        { 
            "to":{
              "phoneNumber": "41793026727",
              "emailAddress": "email@example.com"
            }
        }
    ],
    "text": "A long time ago in a galaxy far, far away..."
}
					
				
					POST /omni/1/text HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xml

<request>
	<destinations>
  	<destination>
			<to>
        <phoneNumber>41793026727</phoneNumber>
        <emailAddress>email@example.com</emailAddress>
      </to>
		</destination>
  </destinations>
	<text>A long time ago in a galaxy far, far away...</text>
</request>
					
				

Response

					HTTP/1.1 200 OK
Content-Type: application/json

{   
    "messages":[   
        {   
            "to":{
              "phoneNumber": "41793026727",
              "emailAddress": "email@example.com"
            },
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 7,
                "name": "PENDING_ENROUTE",
                "description": "Message sent to next instance"
            },
            "messageId": "efcd006b-af37-40e1-9984-09735bf45f17"
        }
    ]
}
					
				
					HTTP/1.1 200 OK
Content-Type: application/xml

<omniResponse>
	<messages>
  	<message>
			<to>
        <phoneNumber>41793026727</phoneNumber>
        <emailAddress>email@example.com</emailAddress>
      </to>
      <status>
				<groupId>0</groupId>
				<groupName>ACCEPTED</groupName>
				<id>0</id>
				<name>MESSAGE_ACCEPTED</name>
				<description>Message accepted</description>
			</status>
			<messageId>4242f196ba50-a356-2f91-831c4aa55f351ed2</messageId>
		</message>
  </messages>
</omniResponse>
					
				

Sending a message with the scenario key

We will attempt to send the message sequentially as defined in a given scenario. If sending over the first defined step fails, we will attempt to send it over the second and so on.

Response format

If successful, the response header HTTP status code will be 200 OK and the message will be sent.

If you try to send the message without authorization, you will receive a 401 Unauthorized error .

OmniResponse

Parameter Type Description
bulkId String The ID that uniquely identifies the request. Bulk ID will be received only when a message is sent to more than one destination address.
messages OmniResponseDetails Array of sent message objects, one object per every message.

OmniResponseDetails

Parameter Type Description
to To The message destination address.
status Status Indicates whether the message is sent successfully, not sent, delivered, not delivered, waiting for delivery or any other possible status.
messageId String The ID that uniquely identifies the sent message.

To

Parameter Type Description
phoneNumber String The message destination phone number.
emailAddress String The message destination email address.

Status

Parameter Type Description
groupId int Status group ID.
groupName String Status group name.
id int Status ID.
name String Status name.
description String Human-readable description of the status.
action String Action that should be taken to eliminate the error.

Additional example

Send multiple messages with a specific scenario key

Request

POST /omni/1/text HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json

{ 
    "destinations":[ 
        { 
            "messageId":"MESSAGE-ID-123-xyz",
            "to":{
              "phoneNumber": "41793026727",
              "emailAddress": "email@example.com"
            }
        },
        { 
            "to":{
              "phoneNumber": "41793026731"
            }
        }
    ],
    "bulkId":"Bulk-ID-12xyz",
    "scenarioKey":"AD9E01A5DC7BEE2C2B828D208182A611",
    "text": "Failover text",
    "mailSubject": "Email subject"
}
POST /omni/1/text HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xml

<request>
    <destinations>
    <destination>
            <messageId>MESSAGE-ID-123-xyz</messageId>
            <to>
        <phoneNumber>41793026727</phoneNumber>
        <emailAddress>email@example.com</emailAddress>
      </to>
        </destination>
        <destination>
            <to>
        <phoneNumber>41793026731</phoneNumber>
      </to>
        </destinations>
  </destinations>
    <bulkId>Bulk-ID-12xyz</bulkId>
    <scenarioKey>AD9E01A5DC7BEE2C2B828D208182A611</scenarioKey>
    <text>Failover text</text>
  <mailSubject>Email subject</mailSubject>
</request>
curl -X POST 
-H "Content-Type: application/json"  \
-H "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ"  \
-d '{ 
    "destinations":[ 
        { 
            "messageId":"MESSAGE-ID-123-xyz",
            "to":{
              "phoneNumber": "41793026727",
              "emailAddress": "email@example.com"
            }
        },
        { 
            "to":{
              "phoneNumber": "41793026731"
            }
        }
    ],
    "bulkId":"Bulk-ID-12xyz",
    "scenarioKey":"AD9E01A5DC7BEE2C2B828D208182A611",
    "text": "Failover text",
    "mailSubject": "Email subject"
}' https://api.infobip.com/1/omni/1/text'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://api.infobip.com/omni/1/text",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{ \"destinations\":[ { \"messageId\":\"MESSAGE-ID-123-xyz\", \"to\":{ \"phoneNumber\": \"41793026727\", \"emailAddress\": \"email@example.com\" } }, { \"to\":{ \"phoneNumber\": \"41793026731\" } } ], \"bulkId\":\"Bulk-ID-12xyz\", \"scenarioKey\":\"AD9E01A5DC7BEE2C2B828D208182A611\", \"text\": \"Failover text\", \"mailSubject\": \"Email subject\" }",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
require 'uri'
require 'net/http'

url = URI("https://api.infobip.com/1/omni/1/text")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = '4f2fb75b-3e6a-159e-34e7-78cb8d8e7a9c'
request.body = "{ \n    \"destinations\":[ \n        { \n            \"messageId\":\"MESSAGE-ID-123-xyz\",\n            \"to\":{\n              \"phoneNumber\": \"41793026727\",\n              \"emailAddress\": \"email@example.com\"\n            }\n        },\n        { \n            \"to\":{\n              \"phoneNumber\": \"41793026731\"\n            }\n        }\n    ],\n    \"bulkId\":\"Bulk-ID-12xyz\",\n    \"scenarioKey\":\"AD9E01A5DC7BEE2C2B828D208182A611\",\n    \"text\": \"Failover text\",\n    \"mailSubject\": \"Email subject\"\n}"

response = http.request(request)
puts response.read_body
import http.client

conn = http.client.HTTPSConnection("api.infobip.com")

payload = "{ \n    \"destinations\":[ \n        { \n            \"messageId\":\"MESSAGE-ID-123-xyz\",\n            \"to\":{\n              \"phoneNumber\": \"41793026727\",\n              \"emailAddress\": \"email@example.com\"\n            }\n        },\n        { \n            \"to\":{\n              \"phoneNumber\": \"41793026731\"\n            }\n        }\n    ],\n    \"bulkId\":\"Bulk-ID-12xyz\",\n    \"scenarioKey\":\"AD9E01A5DC7BEE2C2B828D208182A611\",\n    \"text\": \"Failover text\",\n    \"mailSubject\": \"Email subject\"\n}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ"
    }

conn.request("POST", "/1/omni/1/text", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
HttpResponse<String> response = Unirest.post("https://api.infobip.com/1/omni/1/text")
  .header("content-type", "application/json")
  .header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ")
  .body("{ \n    \"destinations\":[ \n        { \n            \"messageId\":\"MESSAGE-ID-123-xyz\",\n            \"to\":{\n              \"phoneNumber\": \"41793026727\",\n              \"emailAddress\": \"email@example.com\"\n            }\n        },\n        { \n            \"to\":{\n              \"phoneNumber\": \"41793026731\"\n            }\n        }\n    ],\n    \"bulkId\":\"Bulk-ID-12xyz\",\n    \"scenarioKey\":\"AD9E01A5DC7BEE2C2B828D208182A611\",\n    \"text\": \"Failover text\",\n    \"mailSubject\": \"Email subject\"\n}")
  .asString();
var client = new RestClient("https://api.infobip.com/1/omni/1/text");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{ \n    \"destinations\":[ \n        { \n            \"messageId\":\"MESSAGE-ID-123-xyz\",\n            \"to\":{\n              \"phoneNumber\": \"41793026727\",\n              \"emailAddress\": \"email@example.com\"\n            }\n        },\n        { \n            \"to\":{\n              \"phoneNumber\": \"41793026731\"\n            }\n        }\n    ],\n    \"bulkId\":\"Bulk-ID-12xyz\",\n    \"scenarioKey\":\"AD9E01A5DC7BEE2C2B828D208182A611\",\n    \"text\": \"Failover text\",\n    \"mailSubject\": \"Email subject\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var data = JSON.stringify({
  "destinations": [
    {
      "messageId": "MESSAGE-ID-123-xyz",
      "to": {
        "phoneNumber": "41793026727",
        "emailAddress": "email@example.com"
      }
    },
    {
      "to": {
        "phoneNumber": "41793026731"
      }
    }
  ],
  "bulkId": "Bulk-ID-12xyz",
  "scenarioKey": "AD9E01A5DC7BEE2C2B828D208182A611",
  "text": "Failover text",
  "mailSubject": "Email subject"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.infobip.com/1/omni/1/text");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ");

xhr.send(data);

Response

HTTP/1.1 200 OK
Content-Type: application/json

{
    "bulkId": "Bulk-ID-12xyz",
    "messages": [
        {
            "to": {
                "phoneNumber": "41793026727",
                "emailAddress": "email@example.com"
            },
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 7,
                "name": "PENDING_ENROUTE",
                "description": "Message sent to next instance"
            },
            "messageId": "MESSAGE-ID-123-xyz"
        },
        {
            "to": {
                "phoneNumber": "41793026731"
            },
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 7,
                "name": "PENDING_ENROUTE",
                "description": "Message sent to next instance"
            },
            "messageId": "4adbe74a-a600-47b3-9f2e-e410d3224843"
        }
    ]
}
HTTP/1.1 200 OK
Content-Type: application/xml

<omniResponse>
    <bulkId>Bulk-ID-12xyz</bulkId>
    <messages>
    <message>
            <to>
        <phoneNumber>41793026727</phoneNumber>
        <emailAddress>email@example.com</emailAddress>
      </to>
            <status>
                <groupId>0</groupId>
                <groupName>ACCEPTED</groupName>
                <id>0</id>
                <name>MESSAGE_ACCEPTED</name>
                <description>Message accepted</description>
            </status>
            <messageId>MESSAGE-ID-123-xyz</messageId>
        </message>
        <message>
            <to>
        <phoneNumber>41793026731</phoneNumber>
      </to>
            <status>
                <groupId>0</groupId>
                <groupName>ACCEPTED</groupName>
                <id>0</id>
                <name>MESSAGE_ACCEPTED</name>
                <description>Message accepted</description>
            </status>
            <messageId>9304a5a3ab19-1ca1-be74-76ad87651ed25f35</messageId>
    </message>
  </messages>
</omniResponse>