Administrate

Opportunities

You may be interested in our building an ordering system using the API documentation.

Note

The Opportunities endpoint is part of Version 2.5 (v2.5) of the REST API.

Opportunities allow you to capture customers in your Sales Pipeline <salesopps_sales_pipeline>.

Fields

Attributes:

  • age
  • attributes
  • categories
  • categories_order
  • closing_date
  • contact_id
  • created_at
  • external_id
  • id
  • name
  • source_type_id
  • updated_at
  • user_id
  • value

Relations:

  • account - Account
  • children - Opportunity
  • company - Company
  • contact - Contact
  • currency - Currency
  • discount_type - DiscountType
  • documents - OpportunityDocument
  • interests - OpportunityInterest
  • invoice - NominalGroup
  • marketing_activity - MarketingActivity
  • parent - Opportunity
  • promotion_type - PromotionType
  • quotes - OpportunityQuote
  • region - Region
  • registration - Registration
  • resources - OpportunityResource
  • source_type - SourceType
  • step - OpportunityStep
  • user - User
  • values - OpportunityValue

OpportunityInterestDelegate

Attributes:

  • email
  • first_name
  • id
  • last_name
  • notes

Relations:

  • contact - Contact

OpportunityDocument

Attributes:

  • body
  • created_at
  • id
  • name
  • updated_at

Relations:

  • document_template - DocumentTemplate
  • user - User

Opportunity

Attributes:

  • id
  • name

OpportunityInterest

Attributes:

  • id
  • is_discountable
  • is_iht
  • is_reserved
  • is_taxable
  • notes
  • price
  • quantity

Relations:

  • children - OpportunityInterest
  • course - Course
  • delegates - OpportunityInterestDelegate
  • event - Event
  • item - Item
  • tag - Tag
  • tax_type - TaxType
  • track - LearningTrack

OpportunityValue

Attributes:

  • _value
  • attribute_id
  • id

OpportunityQuoteInterest

Attributes:

  • id
  • is_discountable
  • is_iht
  • is_taxable
  • notes
  • price
  • quantity

Relations:

  • children - OpportunityQuoteInterest
  • course - Course
  • event - Event
  • item - Item
  • tax_type - TaxType

OpportunityQuote

Attributes:

  • cover_letter
  • created_at
  • expires_at
  • id
  • updated_at
  • value

Relations:

  • company - Company
  • currency - Currency
  • discount_type - DiscountType
  • interests - OpportunityQuoteInterest
  • region - Region
  • user - User

Getting Opportunities

GET /api/v2.5/crm/opportunities/:id
statuscode 200:no error
statuscode 404:does not exist
Using Python:
import json
import requests

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

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/7 \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/7';

$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;
Example response:
{
    "updated_at": "2016-12-07T11:14:26Z",
    "quotes": [],
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "id": 7,
    "documents": [],
    "marketing_activity": null,
    "children": [],
    "age": 0,
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "current": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "time_in_step": null,
        "time_to_win_days": null,
        "closed": null,
        "attributes": [],
        "transitions": [
            {
                "to_step_id": 2,
                "from_step_id": 1,
                "name": "Go On",
                "triggers": {
                    "create_invoice": true,
                    "create_contact": true,
                    "create_account": true,
                    "create_registration": true
                },
                "required": {},
                "id": 1
            }
        ],
        "id": 1,
        "stage": {
            "status": "Open",
            "id": 1,
            "name": "New"
        }
    },
    "user": {
        "id": 1,
        "name": "John Smith"
    },
    "categories": [],
    "account": null,
    "name": "Demo Opportunity",
    "currency": null,
    "closing_date": null,
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "value": 0.0,
    "source_type": null,
    "contact": null,
    "attributes": {},
    "external_id": null,
    "created_at": "2016-12-07T11:14:26Z"
}

Getting more than one Opportunity

GET /api/v2.5/crm/opportunities
statuscode 200:no error
Using Python:
import json
import requests

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

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities';

$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;
Example response:
[
    {
        "updated_at": "2016-12-07T11:14:27Z",
        "quotes": [],
        "invoice": null,
        "registration": null,
        "promotion_type": null,
        "categories_order": "",
        "id": 8,
        "documents": [],
        "marketing_activity": null,
        "children": [],
        "age": 0,
        "resources": [],
        "interests": [],
        "parent": null,
        "company": {
            "id": 1,
            "name": "Acme Corp"
        },
        "discount_type": null,
        "step": {
            "current": null,
            "name": "Enquiry",
            "probability": null,
            "time_to_win": null,
            "value": null,
            "time_in_step": null,
            "time_to_win_days": null,
            "closed": null,
            "attributes": [],
            "transitions": [
                {
                    "to_step_id": 2,
                    "from_step_id": 1,
                    "name": "Go On",
                    "triggers": {
                        "create_invoice": true,
                        "create_contact": true,
                        "create_account": true,
                        "create_registration": true
                    },
                    "required": {},
                    "id": 1
                }
            ],
            "id": 1,
            "stage": {
                "status": "Open",
                "id": 1,
                "name": "New"
            }
        },
        "user": {
            "id": 1,
            "name": "John Smith"
        },
        "categories": [],
        "account": null,
        "name": "Demo Opportunity",
        "currency": null,
        "closing_date": null,
        "region": {
            "id": "SCO",
            "default_tax": null,
            "name": "Scotland"
        },
        "value": 0.0,
        "source_type": null,
        "contact": null,
        "attributes": {},
        "external_id": null,
        "created_at": "2016-12-07T11:14:27Z"
    }
]

Filtering

The results for a list of Opportunities can be filtered. See Version 2.5 (v2.5) for more details.

Triggers

Important

Changes to the associated Step may fire Triggers (depending on your configuration). However, this will only happen when updating an Opportunity, not on its initial creation.

Validations associated with Transitions will not be enforced by the API.

Creating an Opportunity

POST /api/v2.5/crm/opportunities
statuscode 200:no error
statuscode 400:bad request
Using Python:
import json
import requests

data = {'name': 'Some Opportunity', 'source_type': {'id': 1L}, 'company': {'id': 1L}, 'currency': {'id': u'GBP'}, 'step': {'id': 1L}, 'user': {'id': 1L}, 'region': {'id': u'SCO'}}

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

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities \ 
    -H "Content-Type: application/json" \
    -d '{
    "name": "Some Opportunity", 
    "source_type": {
      "id": 1
    }, 
    "company": {
      "id": 1
    }, 
    "currency": {
      "id": "GBP"
    }, 
    "step": {
      "id": 1
    }, 
    "user": {
      "id": 1
    }, 
    "region": {
      "id": "SCO"
    }
  }' \ 
    -X POST \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities';

$data = array("name" => "Some Opportunity",
  "source_type" => array("id" => 1),
  "company" => array("id" => 1),
  "currency" => array("id" => "GBP"),
  "step" => array("id" => 1),
  "user" => array("id" => 1),
  "region" => array("id" => "SCO"));
$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;
Example response:
{
    "updated_at": "2016-12-07T11:14:32Z",
    "quotes": [],
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "id": 17,
    "documents": [],
    "marketing_activity": null,
    "children": [],
    "age": 0,
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "current": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "time_in_step": null,
        "time_to_win_days": null,
        "closed": null,
        "attributes": [],
        "transitions": [
            {
                "to_step_id": 2,
                "from_step_id": 1,
                "name": "Go On",
                "triggers": {
                    "create_invoice": true,
                    "create_contact": true,
                    "create_account": true,
                    "create_registration": true
                },
                "required": {},
                "id": 1
            }
        ],
        "id": 1,
        "stage": {
            "status": "Open",
            "id": 1,
            "name": "New"
        }
    },
    "user": {
        "id": 1,
        "name": "John Smith"
    },
    "categories": [],
    "account": null,
    "name": "Some Opportunity",
    "currency": {
        "id": "GBP"
    },
    "closing_date": null,
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "value": 0.0,
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "contact": null,
    "attributes": {},
    "external_id": null,
    "created_at": "2016-12-07T11:14:32Z"
}

Updating an Opportunity

PUT /api/v2.5/crm/opportunities/:id
statuscode 200:no error
statuscode 400:bad request
Using Python:
import json
import requests

data = {'name': 'Let us update the name'}

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

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/27 \ 
    -H "Content-Type: application/json" \
    -d '{
    "name": "Let us update the name"
  }' \ 
    -X PUT \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/27';

$data = array("name" => "Let us update the 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;
Example response:
{
    "updated_at": "2016-12-07T11:14:40Z",
    "quotes": [],
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "id": 27,
    "documents": [],
    "marketing_activity": null,
    "children": [],
    "age": 0,
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "current": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "time_in_step": null,
        "time_to_win_days": null,
        "closed": null,
        "attributes": [],
        "transitions": [
            {
                "to_step_id": 2,
                "from_step_id": 1,
                "name": "Go On",
                "triggers": {
                    "create_invoice": true,
                    "create_contact": true,
                    "create_account": true,
                    "create_registration": true
                },
                "required": {},
                "id": 1
            }
        ],
        "id": 1,
        "stage": {
            "status": "Open",
            "id": 1,
            "name": "New"
        }
    },
    "user": {
        "id": 1,
        "name": "John Smith"
    },
    "categories": [],
    "account": null,
    "name": "Let us update the name",
    "currency": {
        "id": "GBP"
    },
    "closing_date": null,
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "value": 0.0,
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "contact": null,
    "attributes": {},
    "external_id": null,
    "created_at": "2016-12-07T11:14:40Z"
}

Deleting an Opportunity

DELETE /api/v2.5/crm/opportunities/:id
statuscode 200:no error
Using Python:
import json
import requests

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

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/6 \ 
    -X DELETE \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/6';

$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;
Example response:
{
    "updated_at": "2016-12-07T11:14:26Z",
    "quotes": [],
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "id": 6,
    "documents": [],
    "marketing_activity": null,
    "children": [],
    "age": 0,
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "current": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "time_in_step": null,
        "time_to_win_days": null,
        "closed": null,
        "attributes": [],
        "transitions": [
            {
                "to_step_id": 2,
                "from_step_id": 1,
                "name": "Go On",
                "triggers": {
                    "create_invoice": true,
                    "create_contact": true,
                    "create_account": true,
                    "create_registration": true
                },
                "required": {},
                "id": 1
            }
        ],
        "id": 1,
        "stage": {
            "status": "Open",
            "id": 1,
            "name": "New"
        }
    },
    "user": {
        "id": 1,
        "name": "John Smith"
    },
    "categories": [],
    "account": null,
    "name": "Some Opportunity",
    "currency": {
        "id": "GBP"
    },
    "closing_date": null,
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "value": 0.0,
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "contact": null,
    "attributes": {},
    "external_id": null,
    "created_at": "2016-12-07T11:14:26Z"
}

Adding Interests to an Opportunity

PUT /api/v2.5/crm/opportunities/:id
statuscode 200:no error
statuscode 400:bad request
Using Python:
import json
import requests

data = {'interests': [{'event': {'id': 1L}, 'delegates': [{'first_name': 'John', 'last_name': 'Smith', 'email': '[email protected]'}]}]}

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

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/1 \ 
    -H "Content-Type: application/json" \
    -d '{
    "interests": [
      {
        "event": {
          "id": 1
        }, 
        "delegates": [
          {
            "first_name": "John", 
            "last_name": "Smith", 
            "email": "[email protected]"
          }
        ]
      }
    ]
  }' \ 
    -X PUT \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/1';

$data = array("interests" => array(array("event" => array("id" => 1),
    "delegates" => array(array("first_name" => "John",
      "last_name" => "Smith",
      "email" => "[email protected]")))));
$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;
Example response:
{
    "updated_at": "2016-12-12T09:58:06Z",
    "quotes": [],
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "id": 1,
    "documents": [],
    "marketing_activity": null,
    "children": [],
    "age": 0,
    "resources": [],
    "interests": [
        {
            "is_reserved": false,
            "is_iht": false,
            "course": null,
            "track": null,
            "notes": null,
            "delegates": [
                {
                    "first_name": "John",
                    "last_name": "Smith",
                    "notes": null,
                    "id": 1,
                    "contact": null,
                    "email": "[email protected]"
                }
            ],
            "children": [],
            "is_taxable": true,
            "item": null,
            "tag": null,
            "id": 1,
            "is_discountable": true,
            "price": null,
            "event": {
                "places_available": null,
                "code": null,
                "start": "2016-12-13T00:00:00Z",
                "title": "Another Tester Event",
                "course": null,
                "id": 1
            },
            "tax_type": null,
            "quantity": null
        }
    ],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "current": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "time_in_step": null,
        "time_to_win_days": null,
        "closed": null,
        "attributes": [],
        "transitions": [
            {
                "to_step_id": 2,
                "from_step_id": 1,
                "name": "Go On",
                "triggers": {
                    "create_invoice": true,
                    "create_contact": true,
                    "create_account": true,
                    "create_registration": true
                },
                "required": {},
                "id": 1
            }
        ],
        "id": 1,
        "stage": {
            "status": "Open",
            "id": 1,
            "name": "New"
        }
    },
    "user": {
        "id": 1,
        "name": "John Smith"
    },
    "categories": [],
    "account": null,
    "name": "Some Opportunity",
    "currency": {
        "id": "GBP"
    },
    "closing_date": null,
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "value": 0.0,
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "contact": null,
    "attributes": {},
    "external_id": null,
    "created_at": "2016-12-12T09:58:06Z"
}

Adding a Document to an Opportunity

Note that the body of the document will be populated for you from the Document Template provided if you omit the body from the request.

PUT /api/v2.5/crm/opportunities/:id
statuscode 200:no error
statuscode 400:bad request
statuscode 404:not found
Using Python:
import json
import requests

data = {'documents': [{'document_template': {'id': 1L}, 'name': 'Test Document', 'user': {'id': 1L}}]}

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

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/1 \ 
    -H "Content-Type: application/json" \
    -d '{
    "documents": [
      {
        "document_template": {
          "id": 1
        }, 
        "name": "Test Document", 
        "user": {
          "id": 1
        }
      }
    ]
  }' \ 
    -X PUT \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/1';

$data = array("documents" => array(array("document_template" => array("id" => 1),
    "name" => "Test Document",
    "user" => array("id" => 1))));
$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;
Example response:
{
    "updated_at": "2016-12-07T11:14:23Z",
    "quotes": [],
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "id": 1,
    "documents": [
        {
            "body": "Acme Corp is great!",
            "name": "Test Document",
            "created_at": "2016-12-07T11:14:23Z",
            "updated_at": "2016-12-07T11:14:23Z",
            "id": 1,
            "user": {
                "id": 1,
                "name": "John Smith"
            },
            "document_template": {
                "id": 1,
                "name": "MergeTemplate"
            }
        }
    ],
    "marketing_activity": null,
    "children": [],
    "age": 0,
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "current": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "time_in_step": null,
        "time_to_win_days": null,
        "closed": null,
        "attributes": [],
        "transitions": [
            {
                "to_step_id": 2,
                "from_step_id": 1,
                "name": "Go On",
                "triggers": {
                    "create_invoice": true,
                    "create_contact": true,
                    "create_account": true,
                    "create_registration": true
                },
                "required": {},
                "id": 1
            }
        ],
        "id": 1,
        "stage": {
            "status": "Open",
            "id": 1,
            "name": "New"
        }
    },
    "user": {
        "id": 1,
        "name": "John Smith"
    },
    "categories": [],
    "account": null,
    "name": "Some Opportunity",
    "currency": {
        "id": "GBP"
    },
    "closing_date": null,
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "value": 0.0,
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "contact": null,
    "attributes": {},
    "external_id": null,
    "created_at": "2016-12-07T11:14:23Z"
}

Generating a Quote for an Opportunity

You can generate a Quote Document for an Opportunity based upon its current Interests <salesopps_interest>.

The following optional fields can be specified:

  • cover_letter - cover text (supports simple HTML), that will be added on a cover page before the quote document.
  • expires_at - the date that the quote should expire in the format YYYY-MM-DD
POST /api/v2.5/crm/opportunities/:id/generate_quote
statuscode 200:no error
statuscode 400:bad request
statuscode 404:not found
Using Python:
import json
import requests

data = {'cover_letter': 'Please find attached your quote as discussed', 'expires_at': '2017-10-01'}

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

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/7/generate_quote \ 
    -H "Content-Type: application/json" \
    -d '{
    "cover_letter": "Please find attached your quote as discussed", 
    "expires_at": "2017-10-01"
  }' \ 
    -X POST \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/7/generate_quote';

$data = array("cover_letter" => "Please find attached your quote as discussed",
  "expires_at" => "2017-10-01");
$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;
Example response:
{
    "quote": {
        "pdf_url": "http://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/quotes/1/render_pdf",
        "id": 1,
        "value": 1050.0
    },
    "message": "Quote generated for opportunity"
}

Getting the PDF for an Opportunity quote

Given the ID of a generated Quote, you can retrieve that quote’s PDF.

GET /api/v2.5/crm/opportunities/quotes/:id/render_pdf
statuscode 200:no error
statuscode 400:bad request
statuscode 404:not found

Sending an Email for an opportunity

The Opportunities API supports sending emails related to a particular Opportunity. The Opportunity must have an associated Owner (an Administrate User) and a Contact (recipient) which will populate the ‘from’ and ‘to’ email addresses respectively.

The following fields can be specified as part of the request body:

  • subject (required) - the subject line for the email
  • body_document_template_id (required) - the id of the DocumentTemplate to use for the body of the email
  • document_attachments (optional) - a list of document attachments
  • document_quotes (optional) - a list of document quotes
  • include_invoice (optional) - a boolean denoting whether to include as an attachment the invoice associated with the Opportunity

DocumentAttachments

  • id (required) - the identifier for an OpportunityDocument on the opportunity
  • name (required) - a name for the attachment

DocumentQuotes

  • id (required) - the identifier for an OpportunityQuote on the opportunity
  • name (required) - a name for the attachment
  • locale (required) - a valid locale for rendering the quote pdf. e.g ‘en’ for English
POST /api/v2.5/crm/opportunities/:id/send_email
statuscode 200:no error
statuscode 400:bad request
statuscode 404:not found
Using Python:
import json
import requests

data = {'document_attachments': [{'id': 8, 'name': 'Test Document'}], 'body_document_template_id': 2L, 'quote_attachments': [{'locale': 'en', 'id': 2L, 'name': 'Quote'}], 'subject': 'Some email subject', 'include_invoice': True}

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

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/25/send_email \ 
    -H "Content-Type: application/json" \
    -d '{
    "document_attachments": [
      {
        "id": 8, 
        "name": "Test Document"
      }
    ], 
    "body_document_template_id": 2, 
    "quote_attachments": [
      {
        "locale": "en", 
        "id": 2, 
        "name": "Quote"
      }
    ], 
    "subject": "Some email subject",
    "include_invoice": true
  }' \ 
    -X POST \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/25/send_email';

$data = array("document_attachments" => array(array("id" => 8,
    "name" => "Test Document")),
  "body_document_template_id" => 2,
  "quote_attachments" => array(array("locale" => "en",
    "id" => 2,
    "name" => "Quote")),
  "subject" => "Some email subject",
  "include_invoice" => true);
$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;
Example response:
{
    "message": "Email scheduled successfully",
    "email": {
        "body": "Basic document template content",
        "to": "[email protected]",
        "from": "[email protected]",
        "attachments": [
            {
                "type": "opportunity_document",
                "id": 8,
                "name": "Test Document"
            },
            {
                "locale": "en",
                "type": "opportunity_quote",
                "id": 2,
                "name": "Quote"
            }
        ],
        "subject": "Some email subject"
    }
}