/services/{serviceUuid}/campaigns/{campaignUuid}Update an existing campaign identified by UUID. It has the same payload as POST request.
Request
Path parameters
service (BM Account) UUID
campaign UUID
Body required
Campaign data to be updated
Campaign Name
New CampaignWhen creating a campaign it can be either active or draft
active, stopped, finished, draft · Example: activeMessaging channel
sms, webpush, email, telegram, rbm, whatsapp · Example: smsSchedule type defines when a campaign is to be executed, now run as soon as saved, once run once in the defined future time, scheduled run per rrule spec
now, once, scheduled · Example: onceThis field defined how and when the campaign is to be execute. In the case of schedule_type once this is time in the format Y-m-d H:i:s in UTC timezone. For scheduled it's iCal RRule string to define recurency
2024-05-01 17:05:00Campaign message content. On the wire this is always a string, but its decoded form depends on sending_type:
sms— plain text (not JSON), e.g.Hello world.-
webpush— a JSON-serialized webpush payload (title/body/icon/image/ target URL); this is JSON but not the Esperanto format. -
all other channels (
email,telegram,rbm,whatsapp) — a JSON-serialized EsperantoMessageBatch(an object with amessagesarray). A single message may also be supplied as the bare message body and is wrapped into aMessageBatchautomatically.
See x-content-schema for the machine-readable definition of each decoded form.
Hello worldWebpush message title
Webpush message content body
Webpush message target URL
Webpush message URL to an icon
Webpush message URL to an image
Campaign messages sender, depending on the sending type, a sender can be sms registered sender id, email email address, whatsapp business phone number id
+41587000000one or more (comma separated) list uuid(s) from which the contacts are to be targeted
cf9eeb30-c1af-11ee-8073-bf4d6e8c1618If all contacts from a list are to be targeted, use all. If you want to apply segmentation by query field set this value to segmentation
all, segmentation · Example: segmentationSegmentation query applied when query_type is segmentation. On the wire this is a JSON-serialized string, but its decoded structure is the SegmentationQuery model: an object with a segmentation array of groups (SegmentationQueryGroup), each combining an operator with an array of rules (SegmentationRule). See x-content-schema below for the full, machine-readable definition of the encoded value.
{"segmentation":[{"operator":"OR","rules":[{"field":"subscription_options_in","condition":"in","value":["7c4c1e07-4c65-4861-ab82-9f8fd9cd3913","94bb60a3-7b4b-4614-913c-0a2760e5f633"],"operator":"AND"}]}]}
Request example
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <access_token>");
var content = new StringContent("{\"name\":\"New Campaign\",\"status\":\"active\",\"sending_type\":\"sms\",\"schedule_type\":\"once\",\"schedule_rrule\":\"2024-05-01 17:05:00\",\"template\":\"Hello world\",\"webpush_title\":\"string\",\"webpush_body\":\"string\",\"webpush_target_url\":\"string\",\"webpush_icon\":\"string\",\"webpush_image\":\"string\",\"sender\":\"+41587000000\",\"recipient_lists\":\"cf9eeb30-c1af-11ee-8073-bf4d6e8c1618\",\"query_type\":\"segmentation\",\"query\":\"{\\\"segmentation\\\":[{\\\"operator\\\":\\\"OR\\\",\\\"rules\\\":[{\\\"field\\\":\\\"subscription_options_in\\\",\\\"condition\\\":\\\"in\\\",\\\"value\\\":[\\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\\",\\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\\"],\\\"operator\\\":\\\"AND\\\"}]}]}\\n\"}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());var options = new RestClientOptions("")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}", Method.Put);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer <access_token>");
var body = "{\"name\":\"New Campaign\",\"status\":\"active\",\"sending_type\":\"sms\",\"schedule_type\":\"once\",\"schedule_rrule\":\"2024-05-01 17:05:00\",\"template\":\"Hello world\",\"webpush_title\":\"string\",\"webpush_body\":\"string\",\"webpush_target_url\":\"string\",\"webpush_icon\":\"string\",\"webpush_image\":\"string\",\"sender\":\"+41587000000\",\"recipient_lists\":\"cf9eeb30-c1af-11ee-8073-bf4d6e8c1618\",\"query_type\":\"segmentation\",\"query\":\"{\\\"segmentation\\\":[{\\\"operator\\\":\\\"OR\\\",\\\"rules\\\":[{\\\"field\\\":\\\"subscription_options_in\\\",\\\"condition\\\":\\\"in\\\",\\\"value\\\":[\\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\\",\\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\\"],\\\"operator\\\":\\\"AND\\\"}]}]}\\n\"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);curl -L -X PUT "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer <access_token>" \
--data-raw '{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
}'var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
};
var data = json.encode({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
});
var dio = Dio();
var response = await dio.request(
'https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}',
options: Options(
method: 'PUT',
headers: headers,
),
data: data,
);
if (response.statusCode == 200) {
print(json.encode(response.data));
}
else {
print(response.statusMessage);
}var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
};
var request = http.Request('PUT', Uri.parse('https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}'));
request.body = json.encode({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
});
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}"
method := "PUT"
payload := strings.NewReader(`{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
}`)
client := &http.Client{}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer <access_token>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}PUT /news/v1/services/{serviceUuid}/campaigns/{campaignUuid} HTTP/1.1
Host: api-cpaas.sms.es
Content-Type: application/json
Accept: application/json
Authorization: Bearer <access_token>
Content-Length: 629
{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
}OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"name\":\"New Campaign\",\"status\":\"active\",\"sending_type\":\"sms\",\"schedule_type\":\"once\",\"schedule_rrule\":\"2024-05-01 17:05:00\",\"template\":\"Hello world\",\"webpush_title\":\"string\",\"webpush_body\":\"string\",\"webpush_target_url\":\"string\",\"webpush_icon\":\"string\",\"webpush_image\":\"string\",\"sender\":\"+41587000000\",\"recipient_lists\":\"cf9eeb30-c1af-11ee-8073-bf4d6e8c1618\",\"query_type\":\"segmentation\",\"query\":\"{\\\"segmentation\\\":[{\\\"operator\\\":\\\"OR\\\",\\\"rules\\\":[{\\\"field\\\":\\\"subscription_options_in\\\",\\\"condition\\\":\\\"in\\\",\\\"value\\\":[\\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\\",\\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\\"],\\\"operator\\\":\\\"AND\\\"}]}]}\\n\"}");
Request request = new Request.Builder()
.url("https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}")
.method("PUT", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer <access_token>")
.build();
Response response = client.newCall(request).execute();Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.put("https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}")
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", "Bearer <access_token>")
.body("{\"name\":\"New Campaign\",\"status\":\"active\",\"sending_type\":\"sms\",\"schedule_type\":\"once\",\"schedule_rrule\":\"2024-05-01 17:05:00\",\"template\":\"Hello world\",\"webpush_title\":\"string\",\"webpush_body\":\"string\",\"webpush_target_url\":\"string\",\"webpush_icon\":\"string\",\"webpush_image\":\"string\",\"sender\":\"+41587000000\",\"recipient_lists\":\"cf9eeb30-c1af-11ee-8073-bf4d6e8c1618\",\"query_type\":\"segmentation\",\"query\":\"{\\\"segmentation\\\":[{\\\"operator\\\":\\\"OR\\\",\\\"rules\\\":[{\\\"field\\\":\\\"subscription_options_in\\\",\\\"condition\\\":\\\"in\\\",\\\"value\\\":[\\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\\",\\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\\"],\\\"operator\\\":\\\"AND\\\"}]}]}\\n\"}")
.asString();const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Authorization", "Bearer <access_token>");
const raw = JSON.stringify({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
});
const requestOptions = {
method: "PUT",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));var settings = {
"url": "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}",
"method": "PUT",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
},
"data": JSON.stringify({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});var data = JSON.stringify({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("PUT", "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <access_token>");
xhr.send(data);val client = OkHttpClient()
val mediaType = "application/json".toMediaType()
val body = """
{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
}
""".trimIndent().toRequestBody(mediaType)
val request = Request.Builder()
.url("https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}")
.put(body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer <access_token>")
.build()
val response = client.newCall(request).execute()#include <stdio.h>
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(curl, CURLOPT_URL, "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer <access_token>");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\"name\":\"New Campaign\",\"status\":\"active\",\"sending_type\":\"sms\",\"schedule_type\":\"once\",\"schedule_rrule\":\"2024-05-01 17:05:00\",\"template\":\"Hello world\",\"webpush_title\":\"string\",\"webpush_body\":\"string\",\"webpush_target_url\":\"string\",\"webpush_icon\":\"string\",\"webpush_image\":\"string\",\"sender\":\"+41587000000\",\"recipient_lists\":\"cf9eeb30-c1af-11ee-8073-bf4d6e8c1618\",\"query_type\":\"segmentation\",\"query\":\"{\\\"segmentation\\\":[{\\\"operator\\\":\\\"OR\\\",\\\"rules\\\":[{\\\"field\\\":\\\"subscription_options_in\\\",\\\"condition\\\":\\\"in\\\",\\\"value\\\":[\\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\\",\\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\\"],\\\"operator\\\":\\\"AND\\\"}]}]}\\n\"}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
CURLcode res = curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
return 0;
}const axios = require('axios');
let data = JSON.stringify({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
});
let config = {
method: 'put',
maxBodyLength: Infinity,
url: 'https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});const https = require('follow-redirects').https;
const fs = require('fs');
let options = {
'method': 'PUT',
'hostname': 'api-cpaas.sms.es',
'path': '/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
},
'maxRedirects': 20
};
const req = https.request(options, function (res) {
let chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
let postData = JSON.stringify({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
});
req.write(postData);
req.end();#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Content-Type": @"application/json",
@"Accept": @"application/json",
@"Authorization": @"Bearer <access_token>"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\"name\":\"New Campaign\",\"status\":\"active\",\"sending_type\":\"sms\",\"schedule_type\":\"once\",\"schedule_rrule\":\"2024-05-01 17:05:00\",\"template\":\"Hello world\",\"webpush_title\":\"string\",\"webpush_body\":\"string\",\"webpush_target_url\":\"string\",\"webpush_icon\":\"string\",\"webpush_image\":\"string\",\"sender\":\"+41587000000\",\"recipient_lists\":\"cf9eeb30-c1af-11ee-8073-bf4d6e8c1618\",\"query_type\":\"segmentation\",\"query\":\"{\\\"segmentation\\\":[{\\\"operator\\\":\\\"OR\\\",\\\"rules\\\":[{\\\"field\\\":\\\"subscription_options_in\\\",\\\"condition\\\":\\\"in\\\",\\\"value\\\":[\\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\\",\\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\\"],\\\"operator\\\":\\\"AND\\\"}]}]}\\n\"}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"PUT"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);open Lwt
open Cohttp
open Cohttp_lwt_unix
let postData = ref {|{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
}|};;
let reqBody =
let uri = Uri.of_string "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}" in
let headers = Header.init ()
|> fun h -> Header.add h "Content-Type" "application/json"
|> fun h -> Header.add h "Accept" "application/json"
|> fun h -> Header.add h "Authorization" "Bearer <access_token>"
in
let body = Cohttp_lwt.Body.of_string !postData in
Client.call ~headers ~body `PUT uri >>= fun (_resp, body) ->
body |> Cohttp_lwt.Body.to_string >|= fun body -> body
let () =
let respBody = Lwt_main.run reqBody in
print_endline (respBody)<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => '{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\\"segmentation\\":[{\\"operator\\":\\"OR\\",\\"rules\\":[{\\"field\\":\\"subscription_options_in\\",\\"condition\\":\\"in\\",\\"value\\":[\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\",\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\"],\\"operator\\":\\"AND\\"}]}]}\\n"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer <access_token>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
<?php
$client = new Client();
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer <access_token>'
];
$body = '{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\\"segmentation\\":[{\\"operator\\":\\"OR\\",\\"rules\\":[{\\"field\\":\\"subscription_options_in\\",\\"condition\\":\\"in\\",\\"value\\":[\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\",\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\"],\\"operator\\":\\"AND\\"}]}]}\\n"
}';
$request = new Request('PUT', 'https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer <access_token>")
$body = @"
{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
}
"@
$response = Invoke-RestMethod "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}" -Method 'PUT' -Headers $headers -Body $body
$response | ConvertTo-Jsonimport requests
import json
url = "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}"
payload = json.dumps({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
})
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)import http.client
import json
conn = http.client.HTTPSConnection("api-cpaas.sms.es")
payload = json.dumps({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
})
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
}
conn.request("PUT", "/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))library(httr)
headers = c(
'Content-Type' = 'application/json',
'Accept' = 'application/json',
'Authorization' = 'Bearer <access_token>'
)
body = '{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\\"segmentation\\":[{\\"operator\\":\\"OR\\",\\"rules\\":[{\\"field\\":\\"subscription_options_in\\",\\"condition\\":\\"in\\",\\"value\\":[\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\",\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\"],\\"operator\\":\\"AND\\"}]}]}\\n"
}';
res <- VERB("PUT", url = "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}", body = body, add_headers(headers))
cat(content(res, 'text'))require "uri"
require "json"
require "net/http"
url = URI("https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer <access_token>"
request.body = JSON.dump({
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
})
response = https.request(request)
puts response.read_body
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::builder()
.build()?;
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("Content-Type", "application/json".parse()?);
headers.insert("Accept", "application/json".parse()?);
headers.insert("Authorization", "Bearer <access_token>".parse()?);
let data = r#"{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"
}"#;
let json: serde_json::Value = serde_json::from_str(&data)?;
let request = client.request(reqwest::Method::from_bytes(b"PUT")?, "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}")
.headers(headers)
.json(&json);
let response = request.send().await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}printf '{"name":"New Campaign","status":"active","sending_type":"sms","schedule_type":"once","schedule_rrule":"2024-05-01 17:05:00","template":"Hello world","webpush_title":"string","webpush_body":"string","webpush_target_url":"string","webpush_icon":"string","webpush_image":"string","sender":"+41587000000","recipient_lists":"cf9eeb30-c1af-11ee-8073-bf4d6e8c1618","query_type":"segmentation","query":"{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"}' | http --follow --timeout 3600 PUT "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}" \
'Content-Type':'application/json' \
'Accept':'application/json' \
'Authorization':'Bearer <access_token>'wget --no-check-certificate --quiet \
--method PUT \
--timeout=0 \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access_token>' \
--body-data '{"name":"New Campaign","status":"active","sending_type":"sms","schedule_type":"once","schedule_rrule":"2024-05-01 17:05:00","template":"Hello world","webpush_title":"string","webpush_body":"string","webpush_target_url":"string","webpush_icon":"string","webpush_image":"string","sender":"+41587000000","recipient_lists":"cf9eeb30-c1af-11ee-8073-bf4d6e8c1618","query_type":"segmentation","query":"{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n"}' \
'https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}'let parameters = """
{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\\"segmentation\\":[{\\"operator\\":\\"OR\\",\\"rules\\":[{\\"field\\":\\"subscription_options_in\\",\\"condition\\":\\"in\\",\\"value\\":[\\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\\",\\"94bb60a3-7b4b-4614-913c-0a2760e5f633\\"],\\"operator\\":\\"AND\\"}]}]}\\n"
}
"""
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api-cpaas.sms.es/news/v1/services/{serviceUuid}/campaigns/{campaignUuid}")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
request.addValue("Bearer <access_token>", forHTTPHeaderField: "Authorization")
request.httpMethod = "PUT"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}
task.resume()Responses
- 200
- 400
- 404
Campaign updated
Campaign Name
New CampaignWhen creating a campaign it can be either active or draft
active, stopped, finished, draft · Example: activeMessaging channel
sms, webpush, email, telegram, rbm, whatsapp · Example: smsSchedule type defines when a campaign is to be executed, now run as soon as saved, once run once in the defined future time, scheduled run per rrule spec
now, once, scheduled · Example: onceThis field defined how and when the campaign is to be execute. In the case of schedule_type once this is time in the format Y-m-d H:i:s in UTC timezone. For scheduled it's iCal RRule string to define recurency
2024-05-01 17:05:00Campaign message content. On the wire this is always a string, but its decoded form depends on sending_type:
sms— plain text (not JSON), e.g.Hello world.-
webpush— a JSON-serialized webpush payload (title/body/icon/image/ target URL); this is JSON but not the Esperanto format. -
all other channels (
email,telegram,rbm,whatsapp) — a JSON-serialized EsperantoMessageBatch(an object with amessagesarray). A single message may also be supplied as the bare message body and is wrapped into aMessageBatchautomatically.
See x-content-schema for the machine-readable definition of each decoded form.
Hello worldWebpush message title
Webpush message content body
Webpush message target URL
Webpush message URL to an icon
Webpush message URL to an image
Campaign messages sender, depending on the sending type, a sender can be sms registered sender id, email email address, whatsapp business phone number id
+41587000000one or more (comma separated) list uuid(s) from which the contacts are to be targeted
cf9eeb30-c1af-11ee-8073-bf4d6e8c1618If all contacts from a list are to be targeted, use all. If you want to apply segmentation by query field set this value to segmentation
all, segmentation · Example: segmentationSegmentation query applied when query_type is segmentation. On the wire this is a JSON-serialized string, but its decoded structure is the SegmentationQuery model: an object with a segmentation array of groups (SegmentationQueryGroup), each combining an operator with an array of rules (SegmentationRule). See x-content-schema below for the full, machine-readable definition of the encoded value.
{"segmentation":[{"operator":"OR","rules":[{"field":"subscription_options_in","condition":"in","value":["7c4c1e07-4c65-4861-ab82-9f8fd9cd3913","94bb60a3-7b4b-4614-913c-0a2760e5f633"],"operator":"AND"}]}]}
Campaign ID.
Campaign's created time in RFC3339 format.
Campaign's updated time in RFC3339 format.
Campaign's next execution time in RFC3339 format.
Campaign's last execution time in RFC3339 format.
{
"name": "New Campaign",
"status": "active",
"sending_type": "sms",
"schedule_type": "once",
"schedule_rrule": "2024-05-01 17:05:00",
"template": "Hello world",
"webpush_title": "string",
"webpush_body": "string",
"webpush_target_url": "string",
"webpush_icon": "string",
"webpush_image": "string",
"sender": "+41587000000",
"recipient_lists": "cf9eeb30-c1af-11ee-8073-bf4d6e8c1618",
"query_type": "segmentation",
"query": "{\"segmentation\":[{\"operator\":\"OR\",\"rules\":[{\"field\":\"subscription_options_in\",\"condition\":\"in\",\"value\":[\"7c4c1e07-4c65-4861-ab82-9f8fd9cd3913\",\"94bb60a3-7b4b-4614-913c-0a2760e5f633\"],\"operator\":\"AND\"}]}]}\n",
"uuid": "string",
"created_dt": "2026-01-01T12:00:00Z",
"updated_dt": "2026-01-01T12:00:00Z",
"next_dt": "2026-01-01T12:00:00Z",
"last_dt": "2026-01-01T12:00:00Z"
}Invalid request
Show child attributes
{
"code": "string",
"message": "string",
"description": "string",
"items": [
{
"name": "string",
"message": "string",
"description": "string"
}
]
}Campaign not found