Update SMS campaign


Simple HTTP PUT request to update SMS campaign. For example to add new recipient

PUT

/sms-campaign/:id/

Parameters
Type
Description
id
integer
Unique ID of SMS campaign that you want to update
Attributes
Type
Description
recipients
list
List of recipients that you want to add to SMS campaign.
phone_campaign
object
Object with phone number. This phone number is visible as campaign sender.
phone_number[phone_number]
string
Phone number that is visible as sender
...
...
...
curl -X POST \
  https://app.userengage.com/api/public/sms-campaign/ \
  -H 'Authorization: Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 91d7f546-f096-b2f6-dd4b-71c031fe9b0b' \
  -d '{
    "name": "Sample SMS campaign",
    "phone_number": {
        "provider": "Phone number provider",
        "phone_number": "123123123",
        "name": "Custom name of your phone number"
    },
    "recipients": [5,6,7,8]
}'
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://app.userengage.com/api/public/sms-campaign/",
  "method": "POST",
  "headers": {
    "Authorization": "Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu",
    "Content-Type": "application/json",
    "Cache-Control": "no-cache",
    "Postman-Token": "bb004971-dce3-d681-83a2-1dd04aca013b"
  },
  "processData": false,
  "data": "{\n    \"name\": \"Sample SMS campaign\",\n    \"phone_number\": {\n        \"provider\": \"Phone number provider\",\n        \"phone_number\": \"123123123\",\n        \"name\": \"Custom name of your phone number\"\n    },\n    \"recipients\": [5,6,7,8]\n}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var data = JSON.stringify({
  "name": "Sample SMS campaign",
  "phone_number": {
    "provider": "Phone number provider",
    "phone_number": "123123123",
    "name": "Custom name of your phone number"
  },
  "recipients": [
    5,6,7,8
  ]
});

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

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

xhr.open("POST", "https://app.userengage.com/api/public/sms-campaign/");
xhr.setRequestHeader("Authorization", "Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Postman-Token", "e9393b13-5308-cc9c-babf-3c611c1022d8");

xhr.send(data);
var request = require("request");

var options = { method: 'POST',
  url: 'https://app.userengage.com/api/public/sms-campaign/',
  headers:
   { 'Postman-Token': '22169a6a-b369-b69d-5d09-0cded0a61147',
     'Cache-Control': 'no-cache',
     'Content-Type': 'application/json',
     Authorization: 'Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu' },
  body:
   { name: 'Sample SMS campaign',
     phone_number:
      { provider: 'Phone number provider',
        phone_number: '123123123',
        name: 'Custom name of your phone number' },
     recipients: [5,6,7,8] },
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://app.userengage.com/api/public/sms-campaign/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Postman-Token' => 'b48699ce-0fcf-b707-0a7e-ec63fcd85c7f',
  'Cache-Control' => 'no-cache',
  'Content-Type' => 'application/json',
  'Authorization' => 'Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu'
));

$request->setBody('{
    "name": "Sample SMS campaign",
    "phone_number": {
        "provider": "Phone number provider",
        "phone_number": "123123123",
        "name": "Custom name of your phone number"
    },
    "recipients": [5,6,7,8]
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
import http.client

conn = http.client.HTTPConnection("https://app.userengage.com/api/public/")

payload = "{\n    \"name\": \"Sample SMS campaign\",\n    \"phone_number\": {\n        \"provider\": \"Phone number provider\",\n        \"phone_number\": \"123123123\",\n        \"name\": \"Custom name of your phone number\"\n    },\n    \"recipients\": [5,6,7,8]\n}"

headers = {
    'Authorization': "Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu",
    'Content-Type': "application/json",
    'Cache-Control': "no-cache",
    'Postman-Token': "e5f4260f-9538-76be-17e3-1ffc66a206c8"
    }

conn.request("POST", "api,public,sms-campaign,", payload, headers)

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

print(data.decode("utf-8"))

Response

{
    "id": 8,
    "name": "Sample SMS campaign",
    "description": "",
    "app": 1,
    "phone_number": {
        "id": 3,
        "app": 1,
        "provider": "Phone number provider",
        "country": "",
        "phone_number": "123123123",
        "name": "Custom name of your phone number",
        "description": "",
        "sms": false,
        "voice": false,
        "price": "0.00",
        "last_used_at": null,
        "created_at": "2018-02-19T13:01:41.083625Z",
        "updated_at": "2018-02-19T13:01:41.083655Z",
        "record_incoming_calls": false
    },
    "type": 1,
    "eta": null,
    "status": 1,
    "recipients": [
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
    ],
    "recipients_ids": "[1,2,3,4,5,6,7,8]",
    "recipients_count": 8,
    "started_at": null,
    "last_message_sent_at": null,
    "finished_at": null,
    "author": 1,
    "created_at": "2018-02-19T13:01:41.097096Z",
    "updated_at": "2018-02-19T13:01:41.097126Z"
}
}