How to Create Consignments Via The API With Your Own Consignment Ids and Item References
The following article will cover how to create a consignment via the API when you are delegating your own carrier consignment numbers and item references/barcodes.
This is an advanced topic, and requires the generation of fully compliant carrier consignment ids and item references - something which Machship typically generates for a consignment.
Note:
- This article will not cover the basics of creating consignments. An article covering consignment creation in depth can be found here: A guide to creating Consignments via the API
- There is a difference in the item object on the endpoint in that article and that discussed below - this is the difference between the createConsignment and the createConsignmentwithComplexItems endpoints, with the latter allowing the setting of additional fields including item references.
Creating Your Consignment
When you are looking to generate your own consignment numbers and item references/barcodes and pass them into Machship you must use the following endpoint to create consignments:
POST /apiv2/consignments/createConsignmentwithComplexItems
The full schema of this endpoint is available in our swagger documentation
here.
When using this endpoint, we have two undocumented fields you will need to add to your payload:
- carrierConsignmentId - sitting at the parent level, this value is the carrier consignment ID, which must follow the carrier specifications including any relevant prefixes that you have generated for this consignment.
- items.consignmentItemReferences.carrierItemReference - This field sits inside an array on the items object, inside the consignmentItemReferences array object and is the barcode that will be used on the label. This barcode must follow the carrier specifications.
- You must set one reference for every quantity on the given line.
An example of how these would be set is:
- {
- "carrierConsignmentId": "2657628002",
- "carrierId": "446",
- //all other consignment data as per schema
- "items": [
- {
- "name": "Pallet",
- "quantity": 2,
- "itemType": "Pallet",
- "standardItem": {
- "weight": 270,
- "length": "117",
- "height": "110",
- "width": "117"
- },
- "consignmentItemReferences": [
- {
- "carrierItemReference": "(00)393168610029113320"
- },
- {
- "carrierItemReference": "(00)393168610029113321"
- }
- ]
- },
- {
- "name": "Pallet",
- "quantity": 1,
- "itemType": "Pallet",
- "standardItem": {
- "weight": 170,
- "length": "110",
- "height": "110",
- "width": "110"
- },
- "consignmentItemReferences": [
- {
- "carrierItemReference": "(00)393168610029113322"
- }
- ]
- }
- ]
- }
After you POST this data to the specified endpoint, check the response.
If you're carrierConsignmentId and carrierItemReference match what you sent in, you've successfully delegated the references.
That's it - you're done!