Scenario: Create
This method allows you to create an OMNI scenario and to define the flow for sending a message.
Resource
https://api.infobip.com/omni/1/scenarios
Parameters
Property name | Type | Description |
---|---|---|
name* | string | OMNI scenario name. |
from | string | Sender used in OMNI scenario's step for sending message. |
channel | string | Channel used in scenario's step for delivering message (SMS , VOICE , VIBER , FACEBOOK , EMAIL , PUSH , VK , WHATSAPP ). |
default | boolean | Indicates if created scenario should be set as a default. |
Request Example
POST /omni/1/scenarios HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
{
"name":"Test SMS or Viber",
"flow": [
{
"from": "InfoSMS",
"channel": "SMS"
},
{
"from": "3045",
"channel": "VIBER"
}
],
"default": false
}
POST /omni/1/scenarios HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xml
<scenario>
<name>Test SMS or Viber</name>
<flow>
<step>
<from>InfoSMS</from>
<channel>SMS</channel>
</step>
<step>
<from>3045</from>
<channel>VIBER</channel>
</step>
</flow>
<default>false</default>
</scenario>
curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' \
-d '{
"name":"Test SMS or Viber",
"flow": [
{
"from": "InfoSMS",
"channel": "SMS"
},
{
"from": "3045",
"channel": "VIBER"
}
],
"default": false
}' https://api.infobip.com/sms/1/omni/1/scenarios
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.infobip.com/omni/1/scenarios",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{ \"name\":\"Test SMS or Viber\", \"flow\": [ { \"from\": \"InfoSMS\", \"channel\": \"SMS\" }, { \"from\": \"3045\", \"channel\": \"VIBER\" } ], \"default\": false }",
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/omni/1/scenarios")
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["content-type"] = 'application/json'
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["accept"] = 'application/json'
request.body = "{\n \"name\": \"Test SMS or Viber\",\n \"flow\": [\n {\n \"channel\": \"SMS\",\n \"from\": \"InfoSms\"\n },\n {\n \"channel\": \"VIBER\",\n \"from\": \"3045\"\n }\n ],\n \"default\": false\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPSConnection("api.infobip.com")
payload = "{\n \"name\": \"Test SMS or Viber\",\n \"flow\": [\n {\n \"channel\": \"SMS\",\n \"from\": \"InfoSms\"\n },\n {\n \"channel\": \"VIBER\",\n \"from\": \"3045\"\n }\n ],\n \"default\": false\n}"
headers = {
'content-type': "application/json",
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'accept': "application/json"
}
conn.request("POST", "/omni/1/scenarios", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
HttpResponse<String> response = Unirest.post("https://api.infobip.com/omni/1/scenarios")
.header("content-type", "application/json")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("accept", "application/json")
.body("{\n \"name\": \"Test SMS or Viber\",\n \"flow\": [\n {\n \"channel\": \"SMS\",\n \"from\": \"InfoSms\"\n },\n {\n \"channel\": \"VIBER\",\n \"from\": \"3045\"\n }\n ],\n \"default\": false\n}")
.asString();
var client = new RestClient("https://api.infobip.com/omni/1/scenarios");
var request = new RestRequest(Method.POST);
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"name\": \"Test SMS or Viber\",\n \"flow\": [\n {\n \"channel\": \"SMS\",\n \"from\": \"InfoSms\"\n },\n {\n \"channel\": \"VIBER\",\n \"from\": \"3045\"\n }\n ],\n \"default\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var data = JSON.stringify({
"name":"Test SMS or Viber",
"flow": [
{
"from": "InfoSMS",
"channel": "SMS"
},
{
"from": "3045",
"channel": "VIBER"
}
],
"default": false
});
xhr.open("POST", "https://api.infobip.com/omni/1/scenarios");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);
Response
{
"key": "CD265875E3A6EA43478D5F37A635BE4A",
"name":"Test SMS or Viber",
"flow": [
{
"from": "InfoSMS",
"channel": "SMS"
},
{
"from": "3045",
"channel": "VIBER"
}
],
"default": false
}
<scenario>
<key>CD265875E3A6EA43478D5F37A635BE4A</key>
<name>Test SMS or Viber</name>
<flow>
<step>
<from>InfoSMS</from>
<channel>SMS</channel>
</step>
<step>
<from>3045</from>
<channel>VIBER</channel>
</step>
</flow>
<default>false</default>
</scenario>
{
"requestError": {
"serviceException": {
"messageId": "INVALID_ARGUMENT",
"text": "Invalid argument"
}
}
}
Response format
If successful, the response header HTTP status code will be 201 CREATED
and the scenario will be created.
If you try to create the scenario without authorization, you will receive a 401 Unauthorized
error.
If you use this method too often in a short period of time, you will get the status code 429 Too Many Requests
. This prevents misusing the method to create a lot of unnecessary scenarios. Note that once you create a scenario, you can always reference it via the scenario key and reuse it as many times you like for sending OMNI messages; there is no need to create a new scenario for each OMNI message.
Scenario
Parameter | Type | Description |
---|---|---|
key | String | Key used to uniquely identify OMNI scenario. |
name | String | OMNI scenario name. |
flow | Step | Sender used in OMNI scenario’s step for sending message. |
default | Boolean | Whether scenario is default. |
Step
Parameter | Type | Description |
---|---|---|
from | String | Sender used in OMNI scenario’s step for sending message. |
channel | String | Channel used in scenario’s step for delivering message (SMS , VOICE ,VIBER ,FACEBOOK ,EMAIL ,PUSH ). |
Default scenario
The first scenario created on the account will be marked as the default scenario. Sending OMNI messages will use that scenario until another one is updated to be default.