Marketing Campaigns

Marketing Campaigns represent collections of marketing activities.

A marketing campaign is a member of the crm module

  • actual_contacts
  • description
  • end_date
  • activities
  • actual_conversions
  • target_submissions
  • company_id
  • tag_id
  • start_date
  • currency
  • tag
  • actual_submissions
  • target_contacts
  • target_conversions
  • is_finished
  • contributions
  • id
  • target_sales
  • name

Getting Marketing Campaigns

GET (/api/v2/crm/marketing_campaigns/:id()

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns/4     -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns/4';
$options = array(
  'http' => array(
    'method'  => 'GET',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

response = requests.get('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns/4',
                         auth=('<username>', '<password>'))

print response.json

Example response:

{
    "actual_contacts": 0,
    "description": "Selling stuff",
    "end_date": "2013-09-01",
    "activities": [],
    "actual_conversions": 0,
    "target_submissions": null,
    "company_id": null,
    "tag_id": null,
    "start_date": "2013-05-20",
    "currency": null,
    "tag": null,
    "actual_submissions": 0,
    "target_contacts": null,
    "target_conversions": null,
    "is_finished": false,
    "contributions": [],
    "id": 4,
    "target_sales": null,
    "name": "My campaign"
}

Getting more than one Marketing Campaign

GET (/api/v2/crm/marketing_campaigns()

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns     -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns';
$options = array(
  'http' => array(
    'method'  => 'GET',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

response = requests.get('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns',
                         auth=('<username>', '<password>'))

print response.json

Example response:

[
    {
        "actual_contacts": 0,
        "description": "Selling stuff",
        "end_date": "2013-09-01",
        "actual_conversions": 0,
        "target_submissions": null,
        "company_id": null,
        "tag_id": null,
        "start_date": "2013-05-20",
        "currency": null,
        "tag": null,
        "actual_submissions": 0,
        "target_contacts": null,
        "target_conversions": null,
        "is_finished": false,
        "contributions": [],
        "id": 2,
        "target_sales": null,
        "name": "My campaign"
    },
    {
        "actual_contacts": 0,
        "description": "Selling more stuff",
        "end_date": "2013-12-31",
        "actual_conversions": 0,
        "target_submissions": null,
        "company_id": null,
        "tag_id": null,
        "start_date": "2013-02-01",
        "currency": null,
        "tag": null,
        "actual_submissions": 0,
        "target_contacts": null,
        "target_conversions": null,
        "is_finished": false,
        "contributions": [],
        "id": 3,
        "target_sales": null,
        "name": "Another campaign"
    }
]

Filtering

The results for a list of marketing_campaigns can be filtered. See Filtering

Creating Marketing Campaigns

POST (/api/v2/crm/marketing_campaigns()

Required fields:

  • start_date
  • name
  • end_date
  • description
  • statuscode 200

    no error

  • statuscode 404

    could not create

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns     -H "Content-Type: application/json"     -k -u (login):(password)     -X POST     -d '{"start_date": "2013-05-20", "name": "My campaign", "end_date": "2013-09-01", "description": "Selling stuff"}'

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns';
$data = array("description" => u'Selling stuff', "start_date" => u'2013-05-20', "end_date" => u'2013-09-01', "name" => u'My campaign');
$options = array(
'http' => array(
'method'  => 'POST',
'content' => json_encode($data),
'header'=>  "Content-Type: application/json\r\n" .
            "Accept: application/json\r\n" .
            "Authorization: Basic " . base64_encode($credentials)
)
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

data = {u'description': u'Selling stuff', u'start_date': u'2013-05-20', u'end_date': u'2013-09-01', u'name': u'My campaign'}

response = requests.post('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns',
                        data=json.dumps(data),
                        headers={'content-type': 'application/json'},
                        auth=('<username>', '<password>'))

print response.json

Example response:

{
    "actual_contacts": 0,
    "description": "Selling stuff",
    "end_date": "2013-09-01",
    "activities": [],
    "actual_conversions": 0,
    "target_submissions": null,
    "company_id": null,
    "tag_id": null,
    "start_date": "2013-05-20",
    "currency": null,
    "tag": null,
    "actual_submissions": 0,
    "target_contacts": null,
    "target_conversions": null,
    "is_finished": false,
    "contributions": [],
    "id": 4,
    "target_sales": null,
    "name": "My campaign"
}

Updating Marketing Campaigns

PUT (/api/v2/crm/marketing_campaigns/(int: id)

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns/6     -H "Content-Type: application/json"     -k -u (login):(password)     -X PUT     -d '{"name": "My new value for name", "start_date": "2010-01-25"}'

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns/6';
$data = array("name" => u'My new value for name', "start_date" => u'2010-01-25');
$options = array(
'http' => array(
'method'  => 'PUT',
'content' => json_encode($data),
'header'=>  "Content-Type: application/json\r\n" .
            "Accept: application/json\r\n" .
            "Authorization: Basic " . base64_encode($credentials)
)
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

data = {u'name': u'My new value for name', u'start_date': u'2010-01-25'}

response = requests.put('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns/6',
                        data=json.dumps(data),
                        headers={'content-type': 'application/json'},
                        auth=('<username>', '<password>'))

print response.json

Example response:

{
    "actual_contacts": 0,
    "description": "Selling stuff",
    "end_date": "2013-09-01",
    "activities": [],
    "actual_conversions": 0,
    "target_submissions": null,
    "company_id": null,
    "tag_id": null,
    "start_date": "2010-01-25",
    "currency": null,
    "tag": null,
    "actual_submissions": 0,
    "target_contacts": null,
    "target_conversions": null,
    "is_finished": false,
    "contributions": [],
    "id": 6,
    "target_sales": null,
    "name": "My new value for name"
}

Deleting Marketing Campaigns

DELETE (/api/v2/crm/marketing_campaigns/(int: id)

  • statuscode 200

    deleted entity successfully

  • statuscode 404

    entity not found

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns/1     -X DELETE -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns/1';
$options = array(
  'http' => array(
    'method'  => 'DELETE',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

response = requests.delete('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/marketing_campaigns/1',
                         auth=('<username>', '<password>'))

print response.json

Example response:

{
    "actual_contacts": 0,
    "description": "Selling stuff",
    "end_date": "2013-09-01",
    "activities": [],
    "actual_conversions": 0,
    "target_submissions": null,
    "company_id": null,
    "tag_id": null,
    "start_date": "2013-05-20",
    "currency": null,
    "tag": null,
    "actual_submissions": 0,
    "target_contacts": null,
    "target_conversions": null,
    "is_finished": false,
    "contributions": [],
    "id": 1,
    "target_sales": null,
    "name": "My campaign"
}