×

This API allows you to update all the parameters of a campaign that has not started. Campaign details can be updated before send_at time is passed. Once send_at time is passed only action, status_callback, call_status_callback and call_schedule_callback can be updated.

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.

curl --location --request PUT 'https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/campaigns/<id>' 
--header 'Content-Type: application/json' 
--data-raw '{
    "campaigns": [
        {
            "name": "holi_campaign",
            "type": "trans",
            "caller_id": "03349360005",
            "url": "https://my.exotel.com/<your_sid>/exoml/start_voice/123",
            "from": [
                "+917987616844"
            ],
            "retries": {
                "number_of_retries": 2,
                "interval_mins": 1,
                "mechanism": "Exponential",
                "on_status": [
                    "busy"
                ]
            },
            "status_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d",
            "call_status_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d",
            "call_schedule_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d"
        }
    ]
}'
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: 
      [ { 
      name: "holi_campaign",
      type: "trans",
      caller_id: "03349360005",
      url: "https://my.exotel.com/<your_sid>/exoml/start_voice/123",
      from: [
          "+917987616844"
      ],
      retries: {
          "number_of_retries": 2,
          "interval_mins": 1,
          "mechanism": "Exponential",
          "on_status": [
              "busy"
          ]
      },
      status_callback: "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d",
      call_status_callback: "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d",
      call_schedule_callback: "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d" } ] },
  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": [
        {
            "name": "holi_campaign",
            "type": "trans",
            "caller_id": "03349360005",
            "url": "https://my.exotel.com/<your_sid>/exoml/start_voice/123",
            "from": [
                "+917987616844"
            ],
            "retries": {
                "number_of_retries": 2,
                "interval_mins": 1,
                "mechanism": "Exponential",
                "on_status": [
                    "busy"
                ]
            },
            "status_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d",
            "call_status_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d",
            "call_schedule_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d"
        }
    ]
}',
  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": [
        {
            "name": "holi_campaign",
            "type": "trans",
            "caller_id": "03349360005",
            "url": "https://my.exotel.com/<your_sid>/exoml/start_voice/123",
            "from": [
                "+917987616844"
            ],
            "retries": {
                "number_of_retries": 2,
                "interval_mins": 1,
                "mechanism": "Exponential",
                "on_status": [
                    "busy"
                ]
            },
            "status_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d",
            "call_status_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d",
            "call_schedule_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d"
        }
    ]
}
        })
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>"
      payload := strings.NewReader(
           { 
                { "campaigns": [ 
                { "name": "holi_campaign", 
                  "type": "trans", 
                  "caller_id": "03349360005", 
                  "url": "https://my.exotel.com/<your_sid>/exoml/start_voice/123", 
                  "from": [ "+917987616844" ], 
                  "retries": 
                       { "number_of_retries": 2, 
                         "interval_mins": 1, 
                         "mechanism": "Exponential", 
                         "on_status": [ "busy" ] 
                       }, 
                 "status_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d", 
                 "call_status_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d", 
                 "call_schedule_callback": "https://webhook.site/a5b59df3-c1b6-4a93-aa1a-75f2c8a3721d" 
                 } ] } })
      }]
    }`)

	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": "Created",
                "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"
            }
        }
    ]
}