Update Campaigns

The campaigns PUT function allows you to update a campaign with the supplied fields.

Overview

While createdDate, and modifiedDate are given when retrieving a campaign object, they should be left off the PUT function body because they are set by the service. ID is set in the URL so you do not need to put it in the request body. The campaignTypeId, name, and archived fields are required. The description field is optional but it will replace the original description field with null if it is not supplied.

On success, a 201 code is returned with the created campaign.

This request requires an access token with “campaigns-read” scope.

URI

PUT: https://rest.bronto.com/campaigns/{campaignId}

Parameters

Parameter Type Description
campaignId Required number The ID of the campaign you want to update.

Request Body

The campaign data used to update the campaign.

{
  "campaignTypeId": number,
  "name": string,
  "description": string,
  "archived": boolean
}

Response

A response containing the updated campaign.

{
  "id": number,
  "siteId": number,
  "createdDate": ISO-8601 datetime,
  "modifiedDate": ISO-8601 datetime,
  "campaignTypeId": number,
  "name": string,
  "description": string,
  "archived": boolean
}

Python Code Example

from __future__ import print_function
 
# Requests documentation:  http://docs.python-requests.org/
import requests
 
 
# API authorization
bronto_access_token = "access token"
session = requests.Session()
session.headers["Authorization"] = "Bearer " + bronto_access_token
 
campaign_id = "2473";
 
url_fmt = "https://rest.bronto.com/campaigns/{campaign_id}"
url = url_fmt.format(campaign_id=campaign_id)
 
json = { "campaignTypeId": 1, "name": "campaign name 2", "description": "short description", "archived": False }
 
response = session.put(url, json=json)
 
if response.ok:
    campaign = response.json()
    print("campaign:", campaign)
else:
    print("Could not put campaign (status code={}, content='{}', headers={})".format(
        response.status_code, response.text, response.headers
    ))