Companies

    Get the companies list

    Get the list of companies for the current site.

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/companies
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    An array of the first 10 companies; each object has the following properties:

    • id - the id of the company (integer)
    • siteId - the id of the site (integer)
    • externalId - the external ID (integer)
    • ownBy - the ID of the company's owner (integer)
    • ownDate - the date the owner was added (integer)
    • company - the company's name (string)
    • abn - the company's "Registration"(string)
    • companyTypeId - (integer)
    • customerTypeId - (integer)
    • leadSourceTypeId - (integer)
    • industryTypeId - (integer)
    • ratingTypeId - (integer)

    The response is paginated, you can skip and limit the number if items retrieved. Also take a look at the API V3: sorting and filtering for additional switches you can use.

    You can output additional fields to those listed above as default, see the API v3 Discovery APP for additional details.

    Accepts and returns JSON as Content-Type.


    Request:

    GET /webresources/api/v3/sites/current/companies HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    {  
       "items":[  
          {  
             "id":7193117,
             "siteId":205131,
             "externalId":null,
             "ownBy":1071356,
             "ownDate":"2016-08-25T15:05:41.423",
             "company":"Red Perfumes",
             "abn":"RP",
             "companyTypeId":368469,
             "customerTypeId":292446,
             "leadSourceTypeId":324107,
             "industryTypeId":757976,
             "ratingTypeId":87598
          },
          {  
             "id":7193118,
             "siteId":205131,
             "externalId":null,
             "ownBy":1071356,
             "ownDate":"2016-08-25T15:06:36.733",
             "company":"Blue Perfumes",
             "abn":"BP",
             "companyTypeId":368470,
             "customerTypeId":292452,
             "leadSourceTypeId":324112,
             "industryTypeId":757979,
             "ratingTypeId":87598
          }
       ],
       "totalItemsCount":2,
       "skip":0,
       "limit":10
    }

    Sample code

    Get the list of companies for a site

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/companies",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
    
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Get the list of companies - this only includes the specified fields:

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/companies?fields=externalId
    ,oenBy",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    In this case the response looks like this:

    {  
       "items":[  
          {  
             "externalId":null,
             "ownBy":1071356,
          },
          {  
             "externalId":null,
             "ownBy":1071356,
          }
       ],
       "totalItemsCount":2,
       "skip":0,
       "limit":10
    }

    Get a company's details

    Get a particular company by ID.

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/companies/[company_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    The details for the specified company ID in JSON format.

    • id - the id of the company (integer)
    • siteId - the id of the site (integer)
    • externalId - the external ID (integer)
    • ownBy - the ID of the company's owner (integer)
    • ownDate - the date the owner was added (integer)
    • company - the company's name (string)
    • abn - the company's "Registration"(string)
    • companyTypeId - (integer)
    • customerTypeId - (integer)
    • leadSourceTypeId - (integer)
    • industryTypeId - (integer)
    • ratingTypeId - (integer)

    The response is paginated, you can return only a few of the company's fields. Take a look at the API V3: sorting and filtering for additional switches you can use.

    Accepts and returns JSON as Content-Type.


    Request:

    GET /webresources/api/v3/sites/current/companies/7193118 HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    {
         "id":7193118,
         "siteId":205131,
         "externalId":null,
         "ownBy":1071356,
         "ownDate":"2016-08-25T15:06:36.733",
         "company":"Blue Perfumes",
         "abn":"BP",
         "companyTypeId":368470,
         "customerTypeId":292452,
         "leadSourceTypeId":324112,
         "industryTypeId":757979,
         "ratingTypeId":87598
    }

    Sample code

    Get the details of a company record

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/companies/7193118",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Get the details for a set of companies - the reply only includes the specified fields:

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/companies/7051740?fields=ownBy,ownDate,company",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Get the list of companies owned by a particular user

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
      url: '/webresources/api/v3/sites/current/companies?fields=ownBy,ownDate,company&where={"ownBy":1071356}',
      type: "GET",
      connection: "keep-alive",    
        contentType: "application/json",
      headers: {
        "Authorization": $.cookie('access_token')
      }
    });
    request.done(function(msg) {
      $('.output pre').html(JSON.stringify(msg))
      console.log(msg);
    })
    request.fail(function(jqXHR) {
      console.log("Request failed.");
      console.log("Error code: " + jqXHR.status);
      console.log("Error text: " + jqXHR.statusText);
      console.log("Response text: " + jqXHR.responseText);
    })

    Create a company record

    Create a new company record.

    Request

    • Method: POST
    • Version: v3
    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/companies/
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • externalId - the external ID (integer)
    • ownBy - the ID of the company's owner (integer)
    • ownDate - the date the owner was added (integer)
    • company - the company's name (string)
    • abn - the company's "Registration"(string)
    • companyTypeId - (integer)
    • customerTypeId - (integer)
    • leadSourceTypeId - (integer)
    • industryTypeId - (integer)
    • ratingTypeId - (integer)

    Response

    Returns an empty body if successful or a detailed error message.

    Accepts and returns JSON as Content-Type.


    Request:

    POST /webresources/api/v3/sites/current/companies HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json

    Response:

    {% raw %}HTTP/1.1 201 CREATED
    Location: /webresources/api/v3/sites/current/companies
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample code

    Create a new company

    
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/companies",
    type: "POST",
    connection: "keep-alive",    
        contentType: "application/json",
    processData: false,
    headers: {
        "Authorization": $.cookie('access_token'),
      
    },
      data: JSON.stringify({
            "company": "Pink Perfumes",
            "ownBy":1071356,
            "middleName": "John",
            "abn":"PP",
                    "companyTypeId":368469,
             "customerTypeId":292446,
             "leadSourceTypeId":324107,
             "industryTypeId":757976,
             "ratingTypeId":87598
        })
    });
    request.done(function(msg) {
    console.log(msg);
    })
    request.fail(function(jqXHR) {
    console.log("Request failed.");
    console.log("Error code: " + jqXHR.status);
    console.log("Error text: " + jqXHR.statusText);
    console.log("Response text: " + jqXHR.responseText);
    })

    Edit a company's details

    Edit the details for an existing company record.

    Request

    • Method: PUT
    • Version: v3
    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/companies/[company_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • externalId - the external ID (integer)
    • ownBy - the ID of the company's owner (integer)
    • ownDate - the date the owner was added (integer)
    • company - the company's name (string)
    • abn - the company's "Registration"(string)
    • companyTypeId - (integer)
    • customerTypeId - (integer)
    • leadSourceTypeId - (integer)
    • industryTypeId - (integer)
    • ratingTypeId - (integer)

    Response

    Returns an empty body if successful or a detailed error message.

    Accepts and returns JSON as Content-Type.


    Request:

    PUT /webresources/api/v3/sites/current/companies HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json

    Response:

    {% raw %}
    HTTP/1.1 204 NO CONTENT
    Location: /webresources/api/v3/sites/current/companies/[company_ID]
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample code

    Edit a company's name

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/companies/7193117",
    type: "PUT",
    connection: "keep-alive",    
        contentType: "application/json",
    headers: {
        "Authorization": $.cookie('access_token')
    },
    processData: false,
    data: JSON.stringify({
        "company": "Red Perfume"
    })
    });
    request.done(function(msg) {
    console.log(msg);
    })
    request.fail(function(jqXHR) {
    console.log("Request failed.");
    console.log("Error code: " + jqXHR.status);
    console.log("Error text: " + jqXHR.statusText);
    console.log("Response text: " + jqXHR.responseText);
    })

    Delete a company record

    Delete a company record.

    Request

    • Method: DELETE
    • Version: v3
    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/companies/[company_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    Returns an empty body if successful or a detailed error message.


    Request:

    DELETE /webresources/api/v3/sites/current/companies/368469 HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    
    HTTP/1.1 204 NO CONTENT
    Location: /webresources/api/v3/sites/current/companies/[company_ID]
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample code

    Delete a company record by ID

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/companies/368469",
        type: "DELETE",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function(msg) {
        console.log(msg);
    })
    request.fail(function(jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })