×

While you can update all the parameters of a campaign that has not started. For a campaign that is in progress you can 'pause' or 'resume' or 'mark as completed' specified by the parameter below. Additionally, any completed campaign can be marked as 'archived'.

PUT

https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/campaigns/<id>

Replace <your_api_key> and <your_api_token> with the API key and token created by you. Similarly, replace <your_sid> with your “Account sid” value. These values are available in the API settings page of your Exotel Dashboard. Replace <id> with the campaign id.

Parameter Name

Type & Value

action

A parameter which can control the action of a created campaign. The below values (string) can be passed:

  • pause - Stop calling more numbers as part of the campaign that is in progress. We can pause only created and in-progress campaign
  • resume - Resume calling numbers that were not called. We can resume only paused campaign
  • complete - Mark the entire campaign as Completed. Remaining numbers are marked as Failed. We can mark only paused campaign as completed
  • archive - Mark a campaign as archived. Only completed campaign can be marked as archived
 curl -X PUT https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/campaigns/<id> 
 -d '{"campaigns":[{"action":"pause"}]}'
var request = require("request");
var accountSid = "XXXXXXXXX";
var accountToken = "YYYYYYYYY";
var authKey = "ZZZZZZZZZZ";

var encoding = Buffer.from(authKey + ':' + accountToken).toString('base64')

var options = { method: 'PUT',
  url: 'https://api.exotel.com/v2/accounts/'+ accountSid +'/campaigns/6d49fb6fe1ee4abc8b2c4ea5d2f4015a',
  headers: 
   {
     Authorization: 'Basic ' + encoding,
     'Content-Type': 'application/json' 
    },
  body: 
   { campaigns: 
      [ { caller_id: '0XXXXXXXXX1',
          action: 'pause',
          url: 'http://my.exotel.com/<your_sid>/exoml/start_voice/<app_id>' } ] },
  json: true };

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

  console.log(body);
  console.log(JSON.stringify(body))
});
<?php
$curl = curl_init();
$accountSid = "XXXXXXXXXX";
$accountToken = "YYYYYYYYYY";
$authKey = "ZZZZZZZZZZ";

$encoding = base64_encode($authKey .":". $accountToken);
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.exotel.com/v2/accounts/".$accountSid."/campaigns/6d49fb6fe1ee4abc8b2c4ea5d2f4015a",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => '{
    "campaigns":[{
    "action": "pause",
    "url": "http://my.exotel.com/<your_sid>/exoml/start_voice/<app_id>"}]}',
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic ".$encoding,
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
            
import requests, base64, json

accountSid = "XXXXXXXXX"
authToken = "YYYYYYYYY"
authKey = "ZZZZZZZZZZ"

encoding = base64.b64encode(authKey + ":" + authToken)


url = "https://api.exotel.com/v2/accounts/"+accountSid+"/campaigns/6d49fb6fe1ee4abc8b2c4ea5d2f4015a"

payload = json.dumps({ "campaigns": [{ 
          "action": "0XXXXXXXXX1", 
          "url": "http://my.exotel.com/<your_sid>/exoml/start_voice/<app_id>"]
        })
headers = {
    'Content-Type': "application/json",
    'Authorization': "Basic " + encoding
    }

response = requests.request("PUT", url, data=payload, headers=headers)

print(response.text)
print(json.dumps(json.loads(response.text), indent = 4, sort_keys = True))
package main

import (
	b64 "encoding/base64"
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"
)

func main() {
	// Please provide accountSid, authToken from your Exotel account
	accountSid := "XXXXXXXXX"
	authToken := "YYYYYYYY"
	authKey := "ZZZZZZZZZZ"

	// Encoding the accountSid and authToken, used in Authorization header
	encoding := b64.StdEncoding.EncodeToString([]byte(authKey + ":" + authToken))
	url := "https://api.exotel.com/v2/accounts/" + accountSid + "/campaigns/6d49fb6fe1ee4abc8b2c4ea5d2f4015a"

	payload := strings.NewReader(`{ 
    "campaigns": [{ 
      "action": "pause", 
      "url": "http://my.exotel.com/<your_sid>/exoml/start_voice/<app_id>"
      }]
    }`)

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("Authorization", "Basic "+encoding)
	req.Header.Add("cache-control", "no-cache")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
{
    "request_id": "745d624f47004b71bf72e6cb7d58a25b",
    "method": "POST",
    "http_code": 200,
    "response": [
        {
            "code": 200,
            "error_data": null,
            "status": "success",
            "data": {
                "name": "diwali_campaign",
                "type": "trans",
                "id": "909d2a2ba53ce07f3784668b938eb44914bo",
                "account_sid": "<your_sid>",
                "caller_id": "03349360005",
                "lists": [
                    "71ee118172044804ac5ed2271167c02b"
                ],
                "url": "https://my.exotel.com/<your_sid>/exoml/start_voice/4",
                "retries": {
                    "number_of_retries": 1,
                    "interval_mins": 1,
                    "mechanism": "Exponential",
                    "on_status": [
                        "failed",
                        "busy"
                    ]
                },
                "schedule": {
                    "send_at": "2020-11-24T23:53:19+05:30",
                    "end_at": "2020-12-24T23:53:19+05:30"
                },
                "status_callback": "https://webhook.site/21a6f658-10d4-4b95-9001-c7bf00239502",
                "call_status_callback": "https://webhook.site/21a6f658-10d4-4b95-9001-c7bf00239502",
                "call_schedule_callback": "https://webhook.site/21a6f658-10d4-4b95-9001-c7bf00239502",
                "custom_field": "{"name": "yo"}",
                "date_created": "2020-11-24T23:52:19+05:30",
                "date_updated": "2020-11-24T23:52:19+05:30",
                "status": "paused",
                "call_status_callback_params": null
            },
            "summary": {
                "campaign_sid": "909d2a2ba53ce07f3784668b938eb44914bo",
                "call_scheduled": 0,
                "call_initialized": 0,
                "call_completed": 0,
                "call_failed": 0,
                "call_inprogress": 0,
                "DateCreated": "2020-11-24T23:52:19.625541789+05:30"
            }
        }
    ]
}
  • On success, the HTTP response status code will be 200
  • HTTP body will contain an JSON with details of the updated resource
  • Response parameters are described above