Scenario: Update
This method allows you to update an OMNI scenario.
Resource
https://api.infobip.com/omni/1/scenarios/:key
Parameters
Property name | Type | Description |
---|---|---|
key* | string | Key used to uniquely identify OMNI scenario. |
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 ). |
Request Example
PUT /omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
{
"name":"Test update: SMS or VIBER",
"flow": [
{
"from": "InfoSMS",
"channel": "SMS"
},
{
"from": "0492DF1379D122771652385E4C6743E3",
"channel": "VIBER"
}
],
"default": true
}
PUT /omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xml
<scenario>
<name>Test update: SMS or VIBER</name>
<flow>
<step>
<from>InfoSMS</from>
<channel>SMS</channel>
</step>
<step>
<from>0492DF1379D122771652385E4C6743E3</from>
<channel>VIBER</channel>
</step>
</flow>
<default>true</default>
</scenario>
curl -X PUT \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' \
-d '{
"name":"Test update: SMS or VIBER",
"flow": [
{
"from": "InfoSMS",
"channel": "SMS"
},
{
"from": "0492DF1379D122771652385E4C6743E3",
"channel": "VIBER"
}
],
"default": true
}' https://api.infobip.com/sms/1/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 => "PUT",
CURLOPT_POSTFIELDS => "{ \"name\":\"Test update: SMS or VIBER\", \"flow\": [ { \"from\": \"InfoSMS\", \"channel\": \"SMS\" }, { \"from\": \"0492DF1379D122771652385E4C6743E3\", \"channel\": \"VIBER\" } ], \"default\": true }",
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/CD265875E3A6EA43478D5F37A635BE4A")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["accept"] = 'application/json'
request.body = "{\n \"name\":\"Test update: SMS or VIBER\",\n \"flow\": [\n {\n \"from\": \"InfoSMS\",\n \"channel\": \"SMS\"\n },\n {\n \"from\": \"0492DF1379D122771652385E4C6743E3\",\n \"channel\": \"VIBER\"\n }\n ],\n \"default\": true\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPSConnection("api.infobip.com")
payload = "{\n \"name\":\"Test update: SMS or VIBER\",\n \"flow\": [\n {\n \"from\": \"InfoSMS\",\n \"channel\": \"SMS\"\n },\n {\n \"from\": \"0492DF1379D122771652385E4C6743E3\",\n \"channel\": \"VIBER\"\n }\n ],\n \"default\": true\n}"
headers = {
'content-type': "application/json",
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'accept': "application/json"
}
conn.request("PUT", "/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
HttpResponse<String> response = Unirest.put("https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A")
.header("content-type", "application/json")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("accept", "application/json")
.body("{\n \"name\":\"Test update: SMS or VIBER\",\n \"flow\": [\n {\n \"from\": \"InfoSMS\",\n \"channel\": \"SMS\"\n },\n {\n \"from\": \"0492DF1379D122771652385E4C6743E3\",\n \"channel\": \"VIBER\"\n }\n ],\n \"default\": true\n}")
.asString();
var client = new RestClient("https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A");
var request = new RestRequest(Method.PUT);
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"name\":\"Test update: SMS or VIBER\",\n \"flow\": [\n {\n \"from\": \"InfoSMS\",\n \"channel\": \"SMS\"\n },\n {\n \"from\": \"0492DF1379D122771652385E4C6743E3\",\n \"channel\": \"VIBER\"\n }\n ],\n \"default\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var data = JSON.stringify({
"name":"Test update: SMS or VIBER",
"flow": [
{
"from": "InfoSMS",
"channel": "SMS"
},
{
"from": "0492DF1379D122771652385E4C6743E3",
"channel": "VIBER"
}
],
"default": true
});
xhr.open("PUT", "https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);
Response
{
"key": "CD265875E3A6EA43478D5F37A635BE4A",
"name":"Test update: SMS or VIBER",
"flow": [
{
"from": "InfoSMS",
"channel": "SMS"
},
{
"from": "0492DF1379D122771652385E4C6743E3",
"channel": "VIBER"
}
],
"default": true
}
<scenario>
<key>CD265875E3A6EA43478D5F37A635BE4A</key>
<name>Test update: SMS or VIBER</name>
<flow>
<step>
<from>InfoSMS</from>
<channel>SMS</channel>
</step>
<step>
<from>0492DF1379D122771652385E4C6743E3</from>
<channel>VIBER</channel>
</step>
</flow>
<default>true</default>
</scenario>
{
"requestError": {
"serviceException": {
"messageId": "INVALID_ARGUMENT",
"text": "Invalid argument"
}
}
}
Response format
If successful, the response header HTTP status code will be 200 OK
and the updated scenario will be returned.
If you try to update the scenario without authorization, you will receive a 401 Unauthorized
error.
If you use this method too many times in a short period of time, you will get the status code 429 Too Many Requests
. This prevents misusing the method to update a scenario repeatedly. For that purpose, you can create multiple scenarios and reference them in different situations via the scenario key for sending OMNI messages.
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
If you update a scenario with the default parameter set to true, that scenario will become the default one for your account, replacing the previous default scenario.
Additional example
Caution!
When you try to update the default scenario with the parameter default set to false you will get an error because there can only be one default scenario.
Request:
PUT /omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
{
"default": false
}
PUT /omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/xml
<scenario>
<default>false</default>
</scenario>
curl -X PUT \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' \
-d '{
"default": false
}' https://api.infobip.com/sms/1/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://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 => "PUT",
CURLOPT_POSTFIELDS => "{ \"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/CD265875E3A6EA43478D5F37A635BE4A")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["accept"] = 'application/json'
request.body = "{\n \"default\": false\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPSConnection("api.infobip.com")
payload = "{\n \"default\": false\n}"
headers = {
'content-type': "application/json",
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'accept': "application/json"
}
conn.request("PUT", "/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
HttpResponse<String> response = Unirest.put("https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A")
.header("content-type", "application/json")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("accept", "application/json")
.body("{\n \"default\": false\n}")
.asString();
var client = new RestClient("https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A");
var request = new RestRequest(Method.PUT);
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"default\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var data = JSON.stringify({
"default": false
});
xhr.open("PUT", "https://api.infobip.com/omni/1/scenarios/CD265875E3A6EA43478D5F37A635BE4A");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);
Response:
{
"requestError": {
"serviceException": {
"messageId": "INVALID_ARGUMENT",
"text": "Exactly one scenario must be default."
}
}
}