Create SMS campaign


Create new SMS campaign with HTTP POST request.

POST

/sms-campaign/

Data
Type
Description
name
string
Your custom sms campaign name
phone_number
object
Object with phone number. This phone number is visible as campaign sender
phone_number[provider]
string
Your phone number's provider
phone_number[phone_number]
string
Phone number that is visible as sender
phone_number[name]
string
Custom name of your phone number
recipients
list
List of your SMS campaign recipients' IDs
. . .
. . .
. . .
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": [1,2,3,4]
}'
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\": [1,2,3,4]\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": [
    1,
    2,
    3,
    4
  ]
});

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: [ 1, 2, 3, 4 ] },
  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": [1,2,3,4]
}');

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\": [1,2,3,4]\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
    ],
    "recipients_ids": "[1,2,3,4]",
    "recipients_count": 4,
    "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"
}
}