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 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;

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

Example response:

{
    "updated_at": "2016-12-07T11:14:26Z",
    "currency": null,
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "children": [],
    "documents": [],
    "marketing_activity": null,
    "id": 7,
    "quotes": [],
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "time_in_step": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "current": 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"
    },
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "categories": [],
    "account": null,
    "name": "Demo Opportunity",
    "source_type": null,
    "closing_date": null,
    "created_at": "2016-12-07T11:14:26Z",
    "value": 0.0,
    "contact": null,
    "attributes": {},
    "external_id": null,
    "age": 0
}

Getting more than one Opportunity

GET (/api/v2.5/crm/opportunities()

  • statuscode 200

    no error

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;

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

Example response:

[
    {
        "updated_at": "2016-12-07T11:14:27Z",
        "currency": null,
        "invoice": null,
        "registration": null,
        "promotion_type": null,
        "categories_order": "",
        "children": [],
        "documents": [],
        "marketing_activity": null,
        "id": 8,
        "quotes": [],
        "resources": [],
        "interests": [],
        "parent": null,
        "company": {
            "id": 1,
            "name": "Acme Corp"
        },
        "discount_type": null,
        "step": {
            "time_in_step": null,
            "name": "Enquiry",
            "probability": null,
            "time_to_win": null,
            "value": null,
            "current": 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"
        },
        "region": {
            "id": "SCO",
            "default_tax": null,
            "name": "Scotland"
        },
        "categories": [],
        "account": null,
        "name": "Demo Opportunity",
        "source_type": null,
        "closing_date": null,
        "created_at": "2016-12-07T11:14:27Z",
        "value": 0.0,
        "contact": null,
        "attributes": {},
        "external_id": null,
        "age": 0
    }
]

Filtering

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

Triggers

Creating an Opportunity

POST (/api/v2.5/crm/opportunities()

  • statuscode 200

    no error

  • statuscode 400

    bad request

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;

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

Example response:

{
    "updated_at": "2016-12-07T11:14:32Z",
    "currency": {
        "id": "GBP"
    },
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "children": [],
    "documents": [],
    "marketing_activity": null,
    "id": 17,
    "quotes": [],
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "time_in_step": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "current": 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"
    },
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "categories": [],
    "account": null,
    "name": "Some Opportunity",
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "closing_date": null,
    "created_at": "2016-12-07T11:14:32Z",
    "value": 0.0,
    "contact": null,
    "attributes": {},
    "external_id": null,
    "age": 0
}

Updating an Opportunity

PUT (/api/v2.5/crm/opportunities/:id()

  • statuscode 200

    no error

  • statuscode 400

    bad request

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;

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

Example response:

{
    "updated_at": "2016-12-07T11:14:40Z",
    "currency": {
        "id": "GBP"
    },
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "children": [],
    "documents": [],
    "marketing_activity": null,
    "id": 27,
    "quotes": [],
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "time_in_step": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "current": 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"
    },
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "categories": [],
    "account": null,
    "name": "Let us update the name",
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "closing_date": null,
    "created_at": "2016-12-07T11:14:40Z",
    "value": 0.0,
    "contact": null,
    "attributes": {},
    "external_id": null,
    "age": 0
}

Deleting an Opportunity

DELETE (/api/v2.5/crm/opportunities/:id()

  • statuscode 200

    no error

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;

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

Example response:

{
    "updated_at": "2016-12-07T11:14:26Z",
    "currency": {
        "id": "GBP"
    },
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "children": [],
    "documents": [],
    "marketing_activity": null,
    "id": 6,
    "quotes": [],
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "time_in_step": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "current": 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"
    },
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "categories": [],
    "account": null,
    "name": "Some Opportunity",
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "closing_date": null,
    "created_at": "2016-12-07T11:14:26Z",
    "value": 0.0,
    "contact": null,
    "attributes": {},
    "external_id": null,
    "age": 0
}

Adding Interests to an Opportunity

PUT (/api/v2.5/crm/opportunities/:id()

  • statuscode 200

    no error

  • statuscode 400

    bad request

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": "j.smith@example.org"
          }
        ]
      }
    ]
  }' \
    -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" => "j.smith@example.org")))));
$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 = {'interests': [{'event': {'id': 1L}, 'delegates': [{'first_name': 'John', 'last_name': 'Smith', 'email': 'j.smith@example.org'}]}]}

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

Example response:

{
    "updated_at": "2016-12-12T09:58:06Z",
    "currency": {
        "id": "GBP"
    },
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "children": [],
    "documents": [],
    "marketing_activity": null,
    "id": 1,
    "quotes": [],
    "resources": [],
    "interests": [
        {
            "event": {
                "places_available": null,
                "code": null,
                "course": null,
                "title": "Another Tester Event",
                "start": "2016-12-13T00:00:00Z",
                "id": 1
            },
            "is_reserved": false,
            "is_iht": false,
            "item": null,
            "track": null,
            "notes": null,
            "children": [],
            "delegates": [
                {
                    "first_name": "John",
                    "last_name": "Smith",
                    "notes": null,
                    "id": 1,
                    "contact": null,
                    "email": "j.smith@example.org"
                }
            ],
            "id": 1,
            "is_taxable": true,
            "course": null,
            "tag": null,
            "is_discountable": true,
            "price": null,
            "tax_type": null,
            "quantity": null
        }
    ],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "time_in_step": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "current": 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"
    },
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "categories": [],
    "account": null,
    "name": "Some Opportunity",
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "closing_date": null,
    "created_at": "2016-12-12T09:58:06Z",
    "value": 0.0,
    "contact": null,
    "attributes": {},
    "external_id": null,
    "age": 0
}

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 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;

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

Example response:

{
    "updated_at": "2016-12-07T11:14:23Z",
    "currency": {
        "id": "GBP"
    },
    "invoice": null,
    "registration": null,
    "promotion_type": null,
    "categories_order": "",
    "children": [],
    "documents": [
        {
            "body": "Acme Corp is great!",
            "name": "Test Document",
            "created_at": "2016-12-07T11:14:23Z",
            "updated_at": "2016-12-07T11:14:23Z",
            "document_template": {
                "id": 1,
                "name": "MergeTemplate"
            },
            "user": {
                "id": 1,
                "name": "John Smith"
            },
            "id": 1
        }
    ],
    "marketing_activity": null,
    "id": 1,
    "quotes": [],
    "resources": [],
    "interests": [],
    "parent": null,
    "company": {
        "id": 1,
        "name": "Acme Corp"
    },
    "discount_type": null,
    "step": {
        "time_in_step": null,
        "name": "Enquiry",
        "probability": null,
        "time_to_win": null,
        "value": null,
        "current": 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"
    },
    "region": {
        "id": "SCO",
        "default_tax": null,
        "name": "Scotland"
    },
    "categories": [],
    "account": null,
    "name": "Some Opportunity",
    "source_type": {
        "companies": [
            {
                "id": 1,
                "name": "Acme Corp"
            }
        ],
        "id": 1,
        "name": "Google Search"
    },
    "closing_date": null,
    "created_at": "2016-12-07T11:14:23Z",
    "value": 0.0,
    "contact": null,
    "attributes": {},
    "external_id": null,
    "age": 0
}

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 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;

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

Example response:

{
    "message": "Quote generated for opportunity",
    "quote": {
        "id": 1,
        "pdf_url": "http://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/crm/opportunities/quotes/1/render_pdf",
        "value": 1050.0
    }
}

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 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;

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

Example response:

{
    "email": {
        "attachments": [
            {
                "id": 8,
                "name": "Test Document",
                "type": "opportunity_document"
            },
            {
                "id": 2,
                "locale": "en",
                "name": "Quote",
                "type": "opportunity_quote"
            }
        ],
        "body": "Basic document template content",
        "from": "john@example.com",
        "subject": "Some email subject",
        "to": "john@smith.com"
    },
    "message": "Email scheduled successfully"
}