Shipping options

    List the shipping options in a 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/shippingoptions
      • 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 shipping options; each object has the following properties:

    • id - the id of the shipping option (integer)
    • siteId - the id of the site (integer)
    • "description" - the shipping option's description (string)
    • "price" - (integer)
    • "type" - the type of shipping option (integer)
      • 1 - User defined
      • 2 - Australia Post
      • 3 - FedEx
      • 4 - USPS
      • 5 - Free shipping
      • 6 - DHL
      • 7 - UPS
    • "packageType" - (integer)
    • "taxCodeId" - (integer)
    • "countryCode" - (string)
    • "state" - (string)
    • "postcode" - (string)
    • "productMinWeight" - (integer)
    • "productMinVolume" - (integer)
    • "productMinHeight" - (integer)
    • "productMinDepth" - (integer)
    • "productMaxWeight" - (integer)
    • "productMaxVolume" - (integer)
    • "productMaxHeight" - (integer)
    • "productMaxDepth" - (integer)
    • "totalOrderPriceMin" - (integer)
    • "totalOrderPriceMax" - (integer)
    • "handlingBaseCharge" - (integer)
    • "handlingPerItemCharge" - (integer)
    • "freeThreshold" - (integer)
    • "limitDeliveryTo" - (string)
    • "userAccountNumber" - (string)
    • "userAccountId" - (string)
    • "userAccountKey" - (string)
    • "userAccountPassword" - (string)
    • "upsAccountType" - (integer)
    • "upsPackageType" - (integer)
    • "upsConfirmationType" - (integer)

    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.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/shippingoptions",
        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);
    })

    Sample response

    {
      "items": [
        {
          "id": 68460,
          "siteId": 146985,
          "description": "GB to TW",
          "price": 5,
          "type": 1,
          "packageType": 1,
          "taxCodeId": 0,
          "countryCode": "GB",
          "state": "  ",
          "postcode": "",
          "productMinWeight": -1,
          "productMinVolume": -1,
          "productMinHeight": -1,
          "productMinDepth": -1,
          "productMaxWeight": -1,
          "productMaxVolume": -1,
          "productMaxHeight": -1,
          "productMaxDepth": -1,
          "totalOrderPriceMin": -1,
          "totalOrderPriceMax": -1,
          "handlingBaseCharge": 0,
          "handlingPerItemCharge": 0,
          "freeThreshold": 0,
          "limitDeliveryTo": "SE;CH;TW;TJ;TZ;",
          "userAccountNumber": "",
          "userAccountId": "",
          "userAccountKey": "",
          "userAccountPassword": "",
          "upsAccountType": 0,
          "upsPackageType": 0,
          "upsConfirmationType": 0
        },
        {
          "id": 155083,
          "siteId": 146985,
          "description": "FedEx 1 Day Freight",
          "price": 0,
          "type": 3,
          "packageType": 2,
          "taxCodeId": 826,
          "countryCode": "US",
          "state": "CA",
          "postcode": "90210",
          "productMinWeight": 42,
          "productMinVolume": 2,
          "productMinHeight": 12,
          "productMinDepth": 123,
          "productMaxWeight": 56,
          "productMaxVolume": 5,
          "productMaxHeight": 22,
          "productMaxDepth": 345,
          "totalOrderPriceMin": 224,
          "totalOrderPriceMax": 578,
          "handlingBaseCharge": 5,
          "handlingPerItemCharge": 12,
          "freeThreshold": 0,
          "limitDeliveryTo": "US;",
          "userAccountNumber": "FEDEX-ACCOUNT-NUMBER123123",
          "userAccountId": "2",
          "userAccountKey": "FEDEX-KEY123123",
          "userAccountPassword": "FEDEX-SECURITY-CODE123123",
          "upsAccountType": 1,
          "upsPackageType": 0,
          "upsConfirmationType": 1
        }
      ],
      "totalItemsCount": 2,
      "skip": 0,
      "limit": 10
    }

    Get a shipping option's attributes

    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/shippingoptions/[shipping_option_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    Displays the details for the shipping option as a JSON object

    • id - the id of the shipping option (integer)
    • siteId - the id of the site (integer)
    • "description" - the shipping option's description (string)
    • "price" - (integer)
    • "type" - the type of shipping option (integer)
      • 1 - User defined
      • 2 - Australia Post
      • 3 - FedEx
      • 4 - USPS
      • 5 - Free shipping
      • 6 - DHL
      • 7 - UPS
    • "packageType" - (integer)
    • "taxCodeId" - (integer)
    • "countryCode" - (string)
    • "state" - (string)
    • "postcode" - (string)
    • "productMinWeight" - (integer)
    • "productMinVolume" - (integer)
    • "productMinHeight" - (integer)
    • "productMinDepth" - (integer)
    • "productMaxWeight" - (integer)
    • "productMaxVolume" - (integer)
    • "productMaxHeight" - (integer)
    • "productMaxDepth" - (integer)
    • "totalOrderPriceMin" - (integer)
    • "totalOrderPriceMax" - (integer)
    • "handlingBaseCharge" - (integer)
    • "handlingPerItemCharge" - (integer)
    • "freeThreshold" - (integer)
    • "limitDeliveryTo" - (string)
    • "userAccountNumber" - (string)
    • "userAccountId" - (string)
    • "userAccountKey" - (string)
    • "userAccountPassword" - (string)
    • "upsAccountType" - (integer)
    • "upsPackageType" - (integer)
    • "upsConfirmationType" - (integer)

    Accepts and returns JSON as Content-Type.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/shippingoptions/155083",
        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);
    })

    Sample response

    {
      "id": 155083,
      "siteId": 146985,
      "description": "FedEx 1 Day Freight",
      "price": 0,
      "type": 3,
      "packageType": 2,
      "taxCodeId": 826,
      "countryCode": "US",
      "state": "CA",
      "postcode": "90210",
      "productMinWeight": 42,
      "productMinVolume": 2,
      "productMinHeight": 12,
      "productMinDepth": 123,
      "productMaxWeight": 56,
      "productMaxVolume": 5,
      "productMaxHeight": 22,
      "productMaxDepth": 345,
      "totalOrderPriceMin": 224,
      "totalOrderPriceMax": 578,
      "handlingBaseCharge": 5,
      "handlingPerItemCharge": 12,
      "freeThreshold": 0,
      "limitDeliveryTo": "US;",
      "userAccountNumber": "FEDEX-ACCOUNT-NUMBER123123",
      "userAccountId": "2",
      "userAccountKey": "FEDEX-KEY123123",
      "userAccountPassword": "FEDEX-SECURITY-CODE123123",
      "upsAccountType": 1,
      "upsPackageType": 0,
      "upsConfirmationType": 1
    }

    Create a shipping option

    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/shippingoptions
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Note: Only "user-defined" type shipping ("type": 1) options can be added using this API endpoint.

    Response

    The response should be "201 created" if the shipping option was successfully created.

    Here are the parameters you can use when creating a shipping option:

    • "description" - the shipping option's description (string)
    • "price" - (integer)
    • "type" - the type of shipping option (integer)
      • 1 - User defined
    • "taxCodeId" - (integer)
    • "countryCode" - (string)
    • "postcode" - (string)

    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    	url: "/webresources/api/v3/sites/current/shippingoptions",
        processData: false,
        data: JSON.stringify({
    "description": "My custom shipping option", "type": 1,
    "price": 10,
    "taxCodeId": 0,
    "countryCode": "US",
    "postcode": "01010",
    "limitDeliveryTo": "US;RO"
    }), type: "POST", 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); })

    Update an existing shipping option

    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/shippingoptions/[shipping_option_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Note: Only "user-defined" type shipping ("type": 1) options can be added using this API endpoint.

    Response

    The response should be "204 no content" if the shipping option was successfully modified.

    Here are the parameters you can use when updating a shipping option:

    • "description" - the shipping option's description (string)
    • "price" - (integer)
    • "type" - the type of shipping option (integer)
      • 1 - User defined
    • "taxCodeId" - (integer)
    • "countryCode" - (string)
    • "postcode" - (string)

    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/shippingoptions/155085",
        processData: false,
        data: JSON.stringify({
    "description": "My custom shipping option1",
    "type": 1,
    "price": 100,
    "taxCodeId": 0,
    "countryCode": "US",
    "postcode": "01010",
    "limitDeliveryTo": "US;RO;GB"
    }), type: "PUT", 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); })

    Delete a shipping option

    This section details the endpoints you can use to delete a shipping option.

    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/shippingoptions/[shipping_options_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    The response should be "204 no content" if the shipping option was successfully deleted.


    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/shippingoptions/155085",
        type: "DELETE",    
        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);
    })