Leads
NOTE: Leads are deprecated in favour of Sales Opportunities.
Leads are used to store potential sales against an account and contact.
A lead record holds the following information:
- interests
- probability
- type_id
- sales_invoice_id
- dead_reason_id
- source_1
- contact_id
- creation_date
- discount_rate
- course_id
- partner_id
- id
- account_id
- event_id
- source
- enquiry_id
- type
- owner_id
- status
- description
- status_id
- marketing_activity_id
- tag_id
- discount_id
- date
- name
- dead_reason
- closing_date
- probability_id
- region
- value
- course_category_id
- website_order_id
- initial_contact_id
- currency_code
- is_from_message_center
Getting Leads
GET (/api/v2/crm/leads/:id()
statuscode 200
no error
statuscode 404
does not exist
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads/4 -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads/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/leads/4',
auth=('<username>', '<password>'))
print response.json
Example response:
{
"interests": [],
"probability": null,
"type_id": 1,
"sales_invoice_id": null,
"dead_reason_id": null,
"source_1": null,
"contact_id": 1,
"creation_date": null,
"discount_rate": 0.0,
"course_id": null,
"partner_id": null,
"id": 4,
"account_id": 1,
"event_id": null,
"source": "newspaper",
"enquiry_id": null,
"type": {
"type": null,
"id": 1,
"name": "my lead type"
},
"owner_id": null,
"status": null,
"description": "",
"status_id": null,
"marketing_activity_id": null,
"tag_id": null,
"discount_id": null,
"date": null,
"name": "My lead",
"dead_reason": null,
"closing_date": "2013-12-25T00:00:00",
"probability_id": null,
"region": {
"name": "Test Region",
"default_tax": null,
"countries": [],
"invoice_numbering": "company",
"default_tax_id": null,
"company": {
"registration_numbers": null,
"code": "ACM",
"name": "Acme Corporation",
"settings": {
"time_format": "H:i",
"date_format": "Y-m-d",
"locale": "en_GB",
"week_starts": null,
"non_working_days": null
},
"bank_details": null,
"currency": {
"html_code": null,
"symbol": "\u00a3",
"code": "GBP",
"name": "British Pound Sterling",
"is_base": true
},
"id": 1,
"currency_code": "GBP",
"account_id": null
},
"company_id": 1,
"mapped_countries": [],
"is_hidden": false,
"id": "TEST"
},
"value": null,
"course_category_id": null,
"website_order_id": null,
"initial_contact_id": null,
"currency_code": null,
"is_from_message_center": false
}
Getting more than one Lead
GET (/api/v2/crm/leads()
statuscode 200
no error
statuscode 404
does not exist
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads';
$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/leads',
auth=('<username>', '<password>'))
print response.json
Example response:
[
{
"interests": [],
"probability": null,
"type_id": 1,
"sales_invoice_id": null,
"dead_reason_id": null,
"source_1": null,
"contact_id": 1,
"creation_date": null,
"discount_rate": 0.0,
"course_id": null,
"partner_id": null,
"id": 2,
"account_id": 1,
"event_id": null,
"source": "newspaper",
"enquiry_id": null,
"type": {
"type": null,
"id": 1,
"name": "my lead type"
},
"owner_id": null,
"status": null,
"description": "",
"status_id": null,
"marketing_activity_id": null,
"tag_id": null,
"discount_id": null,
"date": null,
"name": "My lead",
"dead_reason": null,
"closing_date": "2013-12-25T00:00:00",
"probability_id": null,
"region": {
"name": "Test Region",
"default_tax": null,
"countries": [],
"invoice_numbering": "company",
"default_tax_id": null,
"company": {
"registration_numbers": null,
"code": "ACM",
"name": "Acme Corporation",
"settings": {
"time_format": "H:i",
"date_format": "Y-m-d",
"locale": "en_GB",
"week_starts": null,
"non_working_days": null
},
"bank_details": null,
"currency": {
"html_code": null,
"symbol": "\u00a3",
"code": "GBP",
"name": "British Pound Sterling",
"is_base": true
},
"id": 1,
"currency_code": "GBP",
"account_id": null
},
"company_id": 1,
"mapped_countries": [],
"is_hidden": false,
"id": "TEST"
},
"value": null,
"course_category_id": null,
"website_order_id": null,
"initial_contact_id": null,
"currency_code": null,
"is_from_message_center": false
},
{
"interests": [],
"probability": null,
"type_id": 1,
"sales_invoice_id": null,
"dead_reason_id": null,
"source_1": null,
"contact_id": 1,
"creation_date": null,
"discount_rate": 0.0,
"course_id": null,
"partner_id": null,
"id": 3,
"account_id": 1,
"event_id": null,
"source": "google",
"enquiry_id": null,
"type": {
"type": null,
"id": 1,
"name": "my lead type"
},
"owner_id": null,
"status": null,
"description": "",
"status_id": null,
"marketing_activity_id": null,
"tag_id": null,
"discount_id": null,
"date": null,
"name": "Another lead",
"dead_reason": null,
"closing_date": "2013-02-01T00:00:00",
"probability_id": null,
"region": {
"name": "Test Region",
"default_tax": null,
"countries": [],
"invoice_numbering": "company",
"default_tax_id": null,
"company": {
"registration_numbers": null,
"code": "ACM",
"name": "Acme Corporation",
"settings": {
"time_format": "H:i",
"date_format": "Y-m-d",
"locale": "en_GB",
"week_starts": null,
"non_working_days": null
},
"bank_details": null,
"currency": {
"html_code": null,
"symbol": "\u00a3",
"code": "GBP",
"name": "British Pound Sterling",
"is_base": true
},
"id": 1,
"currency_code": "GBP",
"account_id": null
},
"company_id": 1,
"mapped_countries": [],
"is_hidden": false,
"id": "TEST"
},
"value": null,
"course_category_id": null,
"website_order_id": null,
"initial_contact_id": null,
"currency_code": null,
"is_from_message_center": false
}
]
Filtering
The results for a list of leads can be filtered. See Filtering
Creating Leads
POST (/api/v2/crm/leads()
Required fields:
- name
- type_id
- closing_date
- contact_id
- source
- region_id
- account_id
statuscode 200
no error
statuscode 404
could not create
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads -H "Content-Type: application/json" -k -u (login):(password) -X POST -d '{"name": "My lead", "type_id": 1, "closing_date": "2013-12-25", "contact_id": 1, "source": "newspaper", "region_id": "TEST", "account_id": 1}'
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads';
$data = array("region_id" => u'TEST', "type_id" => 1, "closing_date" => u'2013-12-25', "contact_id" => 1, "source" => u'newspaper', "account_id" => 1, "name" => u'My lead');
$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'region_id': u'TEST', u'type_id': 1, u'closing_date': u'2013-12-25', u'contact_id': 1, u'source': u'newspaper', u'account_id': 1, u'name': u'My lead'}
response = requests.post('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads',
data=json.dumps(data),
headers={'content-type': 'application/json'},
auth=('<username>', '<password>'))
print response.json
Example response:
{
"interests": [],
"probability": null,
"type_id": 1,
"sales_invoice_id": null,
"dead_reason_id": null,
"source_1": null,
"contact_id": 1,
"creation_date": null,
"discount_rate": 0.0,
"course_id": null,
"partner_id": null,
"id": 4,
"account_id": 1,
"event_id": null,
"source": "newspaper",
"enquiry_id": null,
"type": {
"type": null,
"id": 1,
"name": "my lead type"
},
"owner_id": null,
"status": null,
"description": "",
"status_id": null,
"marketing_activity_id": null,
"tag_id": null,
"discount_id": null,
"date": null,
"name": "My lead",
"dead_reason": null,
"closing_date": "2013-12-25T00:00:00",
"probability_id": null,
"region": {
"name": "Test Region",
"default_tax": null,
"countries": [],
"invoice_numbering": "company",
"default_tax_id": null,
"company": {
"registration_numbers": null,
"code": "ACM",
"name": "Acme Corporation",
"settings": {
"time_format": "H:i",
"date_format": "Y-m-d",
"locale": "en_GB",
"week_starts": null,
"non_working_days": null
},
"bank_details": null,
"currency": {
"html_code": null,
"symbol": "\u00a3",
"code": "GBP",
"name": "British Pound Sterling",
"is_base": true
},
"id": 1,
"currency_code": "GBP",
"account_id": null
},
"company_id": 1,
"mapped_countries": [],
"is_hidden": false,
"id": "TEST"
},
"value": null,
"course_category_id": null,
"website_order_id": null,
"initial_contact_id": null,
"currency_code": null,
"is_from_message_center": false
}
Updating Leads
PUT (/api/v2/crm/leads/(int: id)
statuscode 200
no error
statuscode 404
does not exist
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads/6 -H "Content-Type: application/json" -k -u (login):(password) -X PUT -d '{"closing_date": "2009-01-25 14:15:16", "name": "My new value for name"}'
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads/6';
$data = array("closing_date" => u'2009-01-25 14:15:16', "name" => u'My new value for name');
$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'closing_date': u'2009-01-25 14:15:16', u'name': u'My new value for name'}
response = requests.put('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads/6',
data=json.dumps(data),
headers={'content-type': 'application/json'},
auth=('<username>', '<password>'))
print response.json
Example response:
{
"interests": [],
"probability": null,
"type_id": 1,
"sales_invoice_id": null,
"dead_reason_id": null,
"source_1": null,
"contact_id": 1,
"creation_date": null,
"discount_rate": 0.0,
"course_id": null,
"partner_id": null,
"id": 6,
"account_id": 1,
"event_id": null,
"source": "newspaper",
"enquiry_id": null,
"type": {
"type": null,
"id": 1,
"name": "my lead type"
},
"owner_id": null,
"status": null,
"description": "",
"status_id": null,
"marketing_activity_id": null,
"tag_id": null,
"discount_id": null,
"date": null,
"name": "My new value for name",
"dead_reason": null,
"closing_date": "2009-01-25T14:15:16",
"probability_id": null,
"region": {
"name": "Test Region",
"default_tax": null,
"countries": [],
"invoice_numbering": "company",
"default_tax_id": null,
"company": {
"registration_numbers": null,
"code": "ACM",
"name": "Acme Corporation",
"settings": {
"time_format": "H:i",
"date_format": "Y-m-d",
"locale": "en_GB",
"week_starts": null,
"non_working_days": null
},
"bank_details": null,
"currency": {
"html_code": null,
"symbol": "\u00a3",
"code": "GBP",
"name": "British Pound Sterling",
"is_base": true
},
"id": 1,
"currency_code": "GBP",
"account_id": null
},
"company_id": 1,
"mapped_countries": [],
"is_hidden": false,
"id": "TEST"
},
"value": null,
"course_category_id": null,
"website_order_id": null,
"initial_contact_id": null,
"currency_code": null,
"is_from_message_center": false
}
Deleting Leads
DELETE (/api/v2/crm/leads/(int: id)
statuscode 200
deleted entity successfully
statuscode 404
entity not found
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads/1 -X DELETE -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/leads/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/leads/1',
auth=('<username>', '<password>'))
print response.json
Example response:
{
"interests": [],
"probability": null,
"type_id": 1,
"sales_invoice_id": null,
"dead_reason_id": null,
"source_1": null,
"contact_id": 1,
"creation_date": null,
"discount_rate": 0.0,
"course_id": null,
"partner_id": null,
"id": 1,
"account_id": 1,
"event_id": null,
"source": "newspaper",
"enquiry_id": null,
"type": {
"type": null,
"id": 1,
"name": "my lead type"
},
"owner_id": null,
"status": null,
"description": "",
"status_id": null,
"marketing_activity_id": null,
"tag_id": null,
"discount_id": null,
"date": null,
"name": "My lead",
"dead_reason": null,
"closing_date": "2013-12-25T00:00:00",
"probability_id": null,
"region": {
"name": "Test Region",
"default_tax": null,
"countries": [],
"invoice_numbering": "company",
"default_tax_id": null,
"company": {
"registration_numbers": null,
"code": "ACM",
"name": "Acme Corporation",
"settings": {
"time_format": "H:i",
"date_format": "Y-m-d",
"locale": "en_GB",
"week_starts": null,
"non_working_days": null
},
"bank_details": null,
"currency": {
"html_code": null,
"symbol": "\u00a3",
"code": "GBP",
"name": "British Pound Sterling",
"is_base": true
},
"id": 1,
"currency_code": "GBP",
"account_id": null
},
"company_id": 1,
"mapped_countries": [],
"is_hidden": false,
"id": "TEST"
},
"value": null,
"course_category_id": null,
"website_order_id": null,
"initial_contact_id": null,
"currency_code": null,
"is_from_message_center": false
}