1. Home
  2. API
  3. Create a campaign

Create a campaign

As always, to authenticate a call Basic Authentication header should be set. See Authentication for details. As soon as BEAR API is REST one (details), to create a campaign we have to use POST request to campaigns.

Only users with admin role can create a campaign.

Code (working example here):

var user = 'admin';
var password = 'test';
var auth = "Basic " + btoa(user + ":" + password);
var urlApi = 'https://apidev.bear2b.com/campaigns';
var params = {name:'test'};
$.ajax({
    processData: true,
    type: 'POST',
    url: urlApi,
    headers: {"Authorization": auth},
    data: JSON.stringify(params),
    dataType: 'json',
    success: function(data){
        var campaign = data[0];
        $('body').html(campaign.id + ' ' + campaign.name);
    },
    error: function(data){
        $('body').html( data.responseJSON.error + ' ' + data.responseJSON.description );
    }
});

Was this article helpful to you? Yes No

How can we help?