Consumer options overview

Consumer options integration

The Consumer Options flow enables you to provide real-time delivery choices - including delivery date, time, and carrier brand - to your customer at point of purchase. After the customer has chosen their preferred option, a consignment is created based on their details, and is allocated to a carrier service based on the customers choice.

The Consumer Options flow is most useful to your business if:

  • You want to present your customer with a dynamic checkout that offers delivery timeslot options.
  • You operate a single warehouse / fulfilment centre.
  • You develop and configure your own e-commerce platform.

There are four steps to the flow:

  1. Get delivery options - Use the Delivery Options endpoint to request a list of available delivery options for the (as yet uncreated) consignment that the customer’s order will generate.
  2. Select delivery option - Use the Select Option endpoint to tell Consignments which option the customer selected. At this point, the Consignments platform has all the information it needs to create and allocate a consignment.
  3. Get the consignment’s labels - Use the Get Labels in Format endpoint to get the delivery label for your consignment.
  4. Manifest the consignment - Use the Manifest Consignments from Query endpoint to send consignment data to the selected carrier.

This section gives more detail on each step of the flow and provides worked examples.


Step 1: Get delivery options

Delivery options endpoint

  POST https://api.electioapp.com/deliveryoptions
  

A “delivery option” is a combination of a delivery date, a start time and an end time. These details form a delivery promise for a consignment. The Consignments platform then recommends a carrier service that can meet the delivery promise, the delivery cost, and the required shipping date, completing the data for each delivery option.

The Delivery Options endpoint takes the details of the (as yet uncreated) consignment. As a minimum, the Consignments API requires you to send package, origin address and destination address data in order to return delivery options.

The endpoint returns an array of {DeliveryOptions} objects. Each {DeliveryOptions} object contains details of a delivery option that can be used to take a consignment with the details you passed in the request. The Consignments platform always returns the cheapest carrier service for each delivery promise, unless using the cheapest service would conflict with existing business rules.

If you do not provide a DeliveryDate in the request, then Consignments returns delivery options for a maximum of fourteen days from the current date. If you provide a DeliveryDate, then Consignments provides options up to and including the supplied date.

The delivery options available for a given consignment can change over time. This is primarily due to differing carrier collection times at each shipping location.

Get delivery options example

The example shows a request to get delivery options for a fairly standard consignment. The API has returned two delivery options, both for Carrier X: one with an {estimatedDeliveryDate} of 2019-06-19 and one with an {estimatedDeliveryDate} of 2019-06-20.

Delivery options request

POST https://api.electioapp.com/deliveryoptions

  {  
  "ConsignmentReferenceProvidedByCustomer": "Your Reference",
  "DeliveryDate": "2019-06-19T00:00:00+00:00",
  "GuaranteedOnly": false,
  "ShippingDate": "2019-06-17T00:00:00+00:00",
  "Packages": [
    {
      "Items": [
        {
          "Sku": "SKU093434",
          "Model": "ITM-002",
          "Description": "Striped Bamboo Red/White",
          "CountryOfOrigin": {
            "IsoCode": {
              "TwoLetterCode": "GB"
            }
          },
          "HarmonisationCode": "Harmonisation_Code",
          "Weight": {
            "Value": 0.5,
            "Unit": "Kg"
          },
          "Dimensions": {
            "Unit": "Cm",
            "Width": 10.0,
            "Length": 10.0,
            "Height": 10.0
          },
          "Value": {
            "Amount": 5.99,
            "Currency": {
              "IsoCode": "GBP"
            }
          },
          "ItemReferenceProvidedByCustomer": "ITEMREF-098",
          "Barcode": {
            "Code": "09887-091221",
            "BarcodeType": "Code39"
          },
          "MetaData": [
            {
              "KeyValue": "Picker",
              "StringValue": "David Thomas"
            }
          ],
          "Quantity": 1,
          "Unit": "Box",
          "HarmonisationKeyWords": [
            "Keyword1"
          ],
          "ContentClassification": "Unrestricted",
          "ContentClassificationDetails": "NotSpecified"
        }
      ],
      "PackageReferenceProvidedByCustomer": "MYPACK-00923",
      "Weight": {
        "Value": 0.5,
        "Unit": "Kg"
      },
      "Dimensions": {
        "Unit": "Cm",
        "Width": 10.0,
        "Length": 10.0,
        "Height": 10.0
      },
      "Description": "Socks",
      "Value": {
        "Amount": 5.99,
        "Currency": {
          "IsoCode": "GBP"
        }
      },
      "Barcode": {
        "Code": "09887-091221",
        "BarcodeType": "Code39"
      },
      "MetaData": [
        {
          "KeyValue": "WMS-REF",
          "IntValue": 77656555
        }
      ]
    }
  ],
  "CustomsDocumentation": {
    "DesignatedPersonResponsible": "Peter McPetersson",
    "ImportersVatNumber": "02345555",
    "CategoryType": "Other",
    "ShipperCustomsReference": "CREF0001",
    "ImportersTaxCode": "TC001",
    "ImportersTelephone": "0161123456",
    "ImportersFax": "01611124547",
    "ImportersEmail": "peter.mcpetersson@test.com",
    "CN23Comments": "Comments",
    "ReferencesOfAttachedInvoices": [
      "INV001"
    ],
    "ReferencesOfAttachedCertificates": [
      "CERT001"
    ],
    "ReferencesOfAttachedLicences": [
      "LIC001"
    ],
    "CategoryTypeExplanation": "Explanation",
    "DeclarationDate": "2019-06-14T00:00:00+00:00",
    "OfficeOfPosting": "Manchester",
    "ReasonForExport": "Sale",
    "ShippingTerms": "CFR",
    "ShippersVatNumber": "874541414",
    "ReceiversTaxCode": "TC5454",
    "ReceiversVatNumber": "8745474",
    "InvoiceDate": "2019-06-14T00:00:00+00:00"
  },
  "Addresses": [
    {
      "AddressType": "Origin",
      "ShippingLocationReference": "EDC5_Electio",
      "IsCached": false
    },
    {
      "AddressType": "Destination",
      "Contact": {
        "Title": "Mr",
        "FirstName": "Peter",
        "LastName": "McPetersson",
        "Telephone": "07702123456",
        "Mobile": "07702123456",
        "LandLine": "0161544123",
        "Email": "peter.mcpetersson@test.com"
      },
      "CompanyName": "Test Company (UK) Ltd.",
      "AddressLine1": "13 Porter Street",
      "AddressLine2": "Pressington",
      "AddressLine3": "Carlsby",
      "Town": "Manchester",
      "Region": "Greater Manchester",
      "Postcode": "M1 5WG",
      "Country": {
        "Name": "Great Britain",
        "IsoCode": {
          "TwoLetterCode": "GB"
        }
      },
      "SpecialInstructions": "Gate code: 4454",
      "LatLong": {
        "Latitude": 53.474220,
        "Longitude": -2.246049
      },
      "IsCached": false
    }
  ],
  "Direction": "Outbound"
}
  

Delivery options response

  {
    "DeliveryOptions": [
        {
            "Reference": "EDO-000-6DX-6XP",
            "EstimatedDeliveryDate": {
                "Date": "2019-06-19T00:00:00+00:00",
                "Guaranteed": true,
                "DayOfWeek": "Wednesday"
            },
            "DeliveryWindow": {
                "Start": "00:00:00",
                "End": "23:59:00",
                "UtcOffset": "+01:00"
            },
            "Carrier": "Carrier X",
            "CarrierService": "Tracked 48 Signed For",
            "CarrierServiceReference": "MPD_T48CX",
            "CarrierServiceTypes": [
                "Standard"
            ],
            "Price": {
                "Net": 27.69,
                "Gross": 33.23,
                "TaxRate": {
                    "Reference": "GB-0.2000",
                    "CountryIsoCode": "GB",
                    "Type": "Standard",
                    "Rate": 0.2
                },
                "VatAmount": 5.54,
                "Currency": {
                    "Name": "Pound Sterling",
                    "IsoCode": "GBP"
                }
            },
            "AllocationCutOff": "2019-06-17T00:00:00+01:00",
            "OperationalCutOff": "2019-06-17T00:00:00+01:00",
            "ServiceDirection": "Inbound, Outbound"
        }
        {
            "Reference": "EDO-000-6DX-6XQ",
            "EstimatedDeliveryDate": {
                "Date": "2019-06-20T00:00:00+00:00",
                "Guaranteed": true,
                "DayOfWeek": "Wednesday"
            },
            "DeliveryWindow": {
                "Start": "00:00:00",
                "End": "23:59:00",
                "UtcOffset": "+01:00"
            },
            "Carrier": "Carrier X",
            "CarrierService": "Tracked 48 Signed For",
            "CarrierServiceReference": "MPD_T48CX",
            "CarrierServiceTypes": [
                "Standard"
            ],
            "Price": {
                "Net": 27.69,
                "Gross": 33.23,
                "TaxRate": {
                    "Reference": "GB-0.2000",
                    "CountryIsoCode": "GB",
                    "Type": "Standard",
                    "Rate": 0.2
                },
                "VatAmount": 5.54,
                "Currency": {
                    "Name": "Pound Sterling",
                    "IsoCode": "GBP"
                }
            },
            "AllocationCutOff": "2019-06-18T00:00:00+01:00",
            "OperationalCutOff": "2019-06-18T00:00:00+01:00",
            "ServiceDirection": "Inbound, Outbound"
        }
    ]
}
  

Both of these options have a time window starting at 00:00 and ending at 23:59. In practice, the carrier is offering to make the delivery at some point on either the 19th or 20th of June (as selected by the customer), but isn’t offering a more specific timeslot on that service.

Note the {Reference} for each delivery option. When the customer selects their preferred delivery option you will need to pass the relevant {Reference} back to Consignments via the Select Option endpoint.

At this point, you would present some or all of the options returned to your customer via your site or app. In the next step, we’ll see how to handle the choice the customer makes.


Step 2: Select a delivery option

Select option endpoint

  POST https://api.electioapp.com/deliveryoptions/select/{deliveryOptionReference}
  

Once the customer has selected an available option, you’ll need to record their choice in Consignments via the Select Option endpoint.

The Consignments platform creates and allocates a consignment using the details supplied previously in the delivery options call, and returns:

  • A link to the consignment resource that was allocated
  • A summary of the carrier service the consignment was allocated to
  • A link to the relevant package labels

Select option example

The example shows a request to select a delivery option that has a {deliveryOptionReference} of EDO-000-6DX-6XP. The Consignments platform creates a consignment with a {consignmentReference} of EC-000-05B-MMQ, which it then allocates to the carrier service associated with delivery option EDO-000-6DX-6XP. The {consignmentReference} is returned and a label link, enabling you to retrieve labels for the consignment.

Select option request

  POST https://api.electioapp.com/deliveryoptions/select/EDO-000-6DX-6XP
  

Select option response

  {
    "StatusCode": 200,
    "ApiLinks": [
        {
            "Rel": "detail",
            "Href": "https://apisandbox.electioapp.com/consignments/EC-000-05B-MMQ"
        },
        {
            "Rel": "label",
            "Href": "https://apisandbox.electioapp.com/labels/EC-000-05B-MMQ"
        }
    ],
    "Description": "Consignment EC-000-05B-MMQ has been successfully allocated with Carrier X Tracked 48 Signed For for shipping on 17/06/2019 00:00:00 +00:00",
    "ConsignmentLegs": [
        {
            "Leg": 1,
            "TrackingReferences": [
                "TRK00009823"
            ],
            "CarrierReference": "CARRIER_X",
            "CarrierServiceReference": null,
            "CarrierName": "Carrier X"
        }
    ],
    "CarrierReference": "CARRIER_X",
    "CarrierName": "Carrier X",
    "CarrierServiceReference": "MPD_T48CX",
    "CarrierServiceName": "Tracked 48 Signed For"
}
  

Step 3: Get a package label

Get labels in format endpoint

  GET https://api.electioapp.com/labels/{consignmentReference}/{labelFormat}
  

When a consignment is allocated, Consignments API generates labels for each package in that consignment. You can retrieve these delivery labels via the Get Labels in Format endpoint.

The Get Labels in Format endpoint takes a {consignmentReference} and {labelFormat} as path parameters. The Consignments API returns all package labels associated with that consignment as a base64-encoded byte array that decodes to the format requested.

Get labels in format example

The example shows a request to get PDF labels for a consignment with a {consignmentReference} of EC-000-05B-MMA. The file data in the response has been truncated for clarity.

You will need to decode the File’s Base64 data in order to view or print the label. If you are unsure how to do so, see the MDN docs for more information.

Get labels in format request

  GET https://api.electioapp.com/labels/EC-000-05B-MMA/pdf
  

Get labels in format response

  {
  "File": "SlZCRVJpMHhMalFLSmRQcjZ ... TVRrNU9ERUtKU1ZGVDBZPQ==",
  "ContentType": "application/pdf"
}
  

Step 4: Manifest the consignment

Manifest consignment from query endpoint

  PUT https://api.electioapp.com/consignments/manifestFromQuery
  

Once you’ve created a consignment, allocated it to a carrier service and printed labels for it, you’re ready to manifest it. To manifest a consignment, use the Manifest Consignments From Query endpoint. In the context of the Consignments platform, the term “manifesting” refers to collating, formatting and transmitting the consignment data to carriers.

The Manifest Consignments From Query endpoint enables you to use a query to select consignments to be manifested. Once Consignments API has added those consignments to a manifest and queued the data to be sent, the Manifest Consignments From Query endpoint returns a Message detailing how many packages met the terms of the query, how many of those consignments were successfully queued, and how many could not be queued.

Manifest consignments from query example

The example shows a request to manifest all consignments that are allocated to Carrier X, shipping from a location with the ShippingLocationReference Location1, and have already had their labels printed. The response indicates that the Consignments platform found 10 consignments meeting these criteria, and that all 10 were successfully queued for manifest.

Manifest consignments from query request

PUT https://api.electioapp.com/consignments/manifestFromQuery

  {
  "ShippingLocationReferences": [
    "Location1"
  ],
  "States": [
    "Allocated"
  ],
  "Carriers": [
    "CARRIER_X"
  ],
  "LabelsPrinted": true
}
  

Manifest consignments from query response

  {
  "Message": "Query found 10 consignment(s). 10 successfully queued to manifest. 0 failed to be added to the queue"
}