Create phone campaign


Create new phone campaign with HTTP POST request.

POST

/phone-campaign/

Data
Type
Description
name
string
Your custom phone 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
. . .
. . .
. . .
curl -X POST \
  https://app.userengage.com/api/public/phone-campaign/ \
  -H 'Authorization: Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 49e6f668-f4b2-44ff-310e-c7eae4d5b4f2' \
  -d '{
    "name": "My first phone campaign ",
    "phone_number": {
        "provider": "Your phone number provider",
        "phone_number": "123456789",
        "name": "Representative phone number"
    }
}'
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://app.userengage.com/api/public/phone-campaign/",
  "method": "POST",
  "headers": {
    "Authorization": "Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu",
    "Content-Type": "application/json",
    "Cache-Control": "no-cache",
    "Postman-Token": "df7692a4-de1b-3ae8-ed73-056bc9da4068"
  },
  "processData": false,
  "data": "{\n    \"name\": \"My first phone campaign \",\n    \"phone_number\": {\n        \"provider\": \"Your phone number provider\",\n        \"phone_number\": \"123456789\",\n        \"name\": \"Representative phone number\"\n    }\n}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var data = JSON.stringify({
  "name": "My first phone campaign ",
  "phone_number": {
    "provider": "Your phone number provider",
    "phone_number": "123456789",
    "name": "Representative phone number"
  }
});

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/phone-campaign/");
xhr.setRequestHeader("Authorization", "Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Postman-Token", "fcf71567-5f1b-8565-23fc-63ad9a0a324f");

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

var options = { method: 'POST',
  url: 'https://app.userengage.com/api/public/phone-campaign/',
  headers:
   { 'Postman-Token': '78e126a9-7d39-2f43-d39b-8b955f7dfab1',
     'Cache-Control': 'no-cache',
     'Content-Type': 'application/json',
     Authorization: 'Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu' },
  body:
   { name: 'My first phone campaign ',
     phone_number:
      { provider: 'Your phone number provider',
        phone_number: '123456789',
        name: 'Representative phone number' } },
  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/phone-campaign/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Postman-Token' => '757f3368-31c3-4608-afdb-cba7b6afe5be',
  'Cache-Control' => 'no-cache',
  'Content-Type' => 'application/json',
  'Authorization' => 'Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu'
));

$request->setBody('{
    "name": "My first phone campaign ",
    "phone_number": {
        "provider": "Your phone number provider",
        "phone_number": "123456789",
        "name": "Representative phone number"
    }
}');

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\": \"My first phone campaign \",\n    \"phone_number\": {\n        \"provider\": \"Your phone number provider\",\n        \"phone_number\": \"123456789\",\n        \"name\": \"Representative phone number\"\n    }\n}"

headers = {
    'Authorization': "Token oPIexKlydeziKDeUjwTkTB6VsOULin2ERaeoX7Wn8iR7T6NTZLr8DQVd4NSwlDpu",
    'Content-Type': "application/json",
    'Cache-Control': "no-cache",
    'Postman-Token': "c4dafaa6-5527-8cbc-3165-e02bc33afa59"
    }

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

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

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

Response


{
    "id": 12,
    "name": "My first phone campaign",
    "description": "",
    "app": 1,
    "phone_number": {
        "id": 2,
        "app": 1,
        "provider": "Your phone number provider",
        "country": "",
        "phone_number": "123456789",
        "name": "Representative phone number",
        "description": "",
        "sms": false,
        "voice": false,
        "price": "0.00",
        "last_used_at": null,
        "created_at": "2018-02-19T11:37:04.727409Z",
        "updated_at": "2018-02-19T11:37:04.727432Z",
        "record_incoming_calls": false
    },
    "status": 1,
    "priority": 1,
    "last_call_at": null,
    "start": null,
    "end": null,
    "created_at": "2018-02-19T11:37:04.733858Z",
    "updated_at": "2018-02-19T11:37:04.733884Z"
}