Scenario: Get
This method allows you to get OMNI scenarios. Specifically, all of our default scenarios can be caught with this method.
Resource
https://api.infobip.com/omni/1/scenarios/:key
Parameters
| Property name | Type | Description |
|---|---|---|
| key | string | Key used to uniquely identify OMNI scenario. |
| default | boolean | Get default scenario. |
| page | integer 0 | OMNI scenarios page to return. This parameter is zero-based, so requesting page 0 will return the first page. |
| limit | integer 100 | Maximal number of OMNI scenarios to return in a single page. |
Request Example
GET /omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
GET /omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xml
curl -X GET
-H 'Accept: application/json'
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
),
));
$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/CD265875E3A6EA43478D5F37A635BE4A")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["accept"] = 'application/json'
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPSConnection("api.infobip.com")
headers = {
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'accept': "application/json"
}
conn.request("GET", "/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
HttpResponse<String> response = Unirest.get("https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("accept", "application/json")
.asString();
var client = new RestClient("https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A");
var request = new RestRequest(Method.GET);
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
IRestResponse response = client.Execute(request);
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A");
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"
}
}
}
{
"requestError": {
"serviceException": {
"messageId": "NOT_FOUND",
"text": "Scenario not found."
}
}
}
Response format
If successful, the response header HTTP status code will be 200 OK and the requested scenario will be returned.
If you try to get the scenario without authorization, you will receive a 401 Unauthorized error.
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). |
Additional example
Get all scenarios
Note
If all scenarios are wanted, key parameter must be omitted.
Request
GET /omni/1/scenarios HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
GET /omni/1/scenarios HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xmlcurl -X GET
-H 'Accept: application/json'
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
https://api.infobip.com/omni/1/scenarios<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://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 => "GET",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
),
));
$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)
request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["accept"] = 'application/json'
response = http.request(request)
puts response.read_bodyimport http.client
conn = http.client.HTTPConnection("api.infobip.com")
headers = {
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'accept': "application/json"
}
conn.request("GET", "/omni/1/scenarios", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))HttpResponse<String> HttpResponse<String> response = Unirest.get("https://api.infobip.com/omni/1/scenarios")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("accept", "application/json")
.asString();var client = new RestClient("https://api.infobip.com/omni/1/scenarios");
var request = new RestRequest(Method.GET);
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
IRestResponse response = client.Execute(request);var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.infobip.com/omni/1/scenarios");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);Response
{
"scenarios": [
{
"key": "CD265875E3A6EA43478D5F37A635BE4A",
"name": "Test SMS or Viber",
"flow": [
{
"from": "InfoSMS",
"channel": "SMS"
},
{
"from": "3045",
"channel": "VIBER"
}
],
"default": false
},
{
"key": "37B93A3C58EAAF4D2B1B35B58526EAAC",
"name": "New scenario",
"flow": [
{
"from": "TestSender",
"channel": "SMS"
},
{
"from": "3045",
"channel": "VIBER"
}
],
"default": true
}
]
}
<scenariosResponse>
<scenarios>
<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>
<scenario>
<key>37B93A3C58EAAF4D2B1B35B58526EAAC</key>
<name>New scenario</name>
<flow>
<step>
<from>TestSender</from>
<channel>SMS</channel>
</step>
<step>
<from>3045</from>
<channel>VIBER</channel>
</step>
</flow>
<default>true</default>
</scenario>
</scenarios>
</scenariosResponse>
{
"requestError": {
"serviceException": {
"messageId": "INVALID_ARGUMENT",
"text": "Invalid argument"
}
}
}Response format
If successful, the response header HTTP status code will be 200 OK and all scenarios will be returned.
If you try to get the scenarios without authorization, you will receive a 401 Unauthorized error.
ScenariosResponse
| Parameter | Type | Description |
|---|---|---|
| scenarios | Scenario | Array of OMNI scenarios. |
Get default scenario
Caution!
Usage of the default and key parameter is exclusive. With the key path parameter, a specific scenario is returned, but with the default query parameter, the default scenario is returned.
Request
GET /omni/1/scenarios?default=true HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
GET /omni/1/scenarios?default=true HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xmlcurl -X GET
-H 'Accept: application/json'
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
https://api.infobip.com/omni/1/scenarios?default=true<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api.infobip.com/omni/1/scenarios?default=true",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
),
));
$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?default=true")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["accept"] = 'application/json'
response = http.request(request)
puts response.read_bodyimport http.client
conn = http.client.HTTPConnection("api.infobip.com")
headers = {
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'accept': "application/json"
}
conn.request("GET", "/omni/1/scenarios?default=true", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))HttpResponse<String> response = Unirest.get("https://api.infobip.com/omni/1/scenarios?default=true")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("accept", "application/json")
.asString();var client = new RestClient("https://api.infobip.com/omni/1/scenarios?default=true");
var request = new RestRequest(Method.GET);
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
IRestResponse response = client.Execute(request);var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.infobip.com/omni/1/scenarios?default=true");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);Response
{
"scenarios": [
{
"key": "37B93A3C58EAAF4D2B1B35B58526EAAC",
"name": "New scenario",
"flow": [
{
"from": "TestSender",
"channel": "SMS"
},
{
"from": "3045",
"channel": "VIBER"
}
],
"default": true
}
]
}
<scenariosResponse>
<scenarios>
<scenario>
<key>37B93A3C58EAAF4D2B1B35B58526EAAC</key>
<name>New scenario</name>
<flow>
<step>
<from>TestSender</from>
<channel>SMS</channel>
</step>
<step>
<from>3045</from>
<channel>VIBER</channel>
</step>
</flow>
<default>true</default>
</scenario>
</scenarios>
</scenariosResponse>
{
"requestError": {
"serviceException": {
"messageId": "NOT_FOUND",
"text": "Scenario not found."
}
}
}