Order Creation and Inventory Totals

Monday, Nov 19, 2018

Order creation is now live in Sandbox!

You can now use it by making POST requests to /orders. The spec has been updated in our docs, along with examples: http://docs.masonhub.co/api/v1#tag/Orders/paths/~1orders/post

One thing to note is that the API will validate any orders you submit to ensure they contain skus that have already been uploaded into the item master. If you’ve already uploaded your catalog, this shouldn’t be a problem. Just keep in mind for testing you have to use valid sku identifiers. As always, the request response messages will let you know if the sku is invalid (as well as any other validation failures).

Example: POST to https://sandbox.masonhub.co/test/api/v1/orders

[
    {
        "customer_identifier": "1111116",
        "order_type": "customer",
        "priority": 100,
        "shipping_provider": "rate_shop",
        "shipper_service_level": "ground",
        "value_added_services": [
            "Complimentary Handkerchief"
        ],
        "special_instructions": "Triple Fold the Sleeves and wrap in Tissue Paper.",
        "gift_message": "Happy Birthday Freddie!",
        "shipping_address_name": "John Jacob JingleHeimer-Schmidt III",
        "shipping_address_street_line_one": "234 House Lane",
        "shipping_address_city": "Little Falls",
        "shipping_address_locale": "NJ",
        "shipping_address_postal_code": "07972",
        "shipping_address_phone_number": "973-999-3333",
        "shipping_address_type": "residential",
        "billing_address_name": "John Jacob JingleHeimer-Schmidt III",
        "billing_address_street_line_one": "234 House Lane",
        "billing_address_city": "Little Falls",
        "billing_address_locale": "NJ",
        "billing_address_postal_code": "07972",
        "billing_address_phone_number": "973-999-3333",
        "billing_address_type": "residential",
        "submitted_at": "2018-08-05T17:32:28Z",
        "line_items": [
            {
            	"sku_customer_id":"SPIR-411003-NVY-M",
            	"quantity":1
            }
    	]
    }
]

orderEvent callbacks are on the way

We have also updated the api spec with the order event callback definition. You can see it here: http://docs.masonhub.co/api/v1#tag/Orders/paths/~1orders/get (click on ‘CALLBACK - order event sent to preconfigured endpoint’ on the right side)

Here is what that looks like:

{
  "callback_url": "https://client.com/api/orderEvent",
  "message_type": "orderEvent",
  "message_id": "0896116f-e54b-4756-9d3e-1b0c4a25d821",
  "data": [
    {
      "order_id": "8f1316d5-859f-4802-98b0-63d03a9517ac",
      "customer_identifier": "12345",
      "status": "packed",
      "shipments": [
        {
          "shipment_id": "88888",
          "shipping_provider": "UPS",
          "shipping_service_level": "ground",
          "tracking_url": "http://ups.com/tracking/1z324897234nferg45",
          "tracking_number": "1z324897234nferg45",
          "shipment_date_time": "2018-08-06T15:11:19Z",
          "shipment_line_items": [
            {
              "customer_identifier": "PNTS-NVY-LG",
              "sku_id": "ea957a79-9605-4948-b9f4-6c115d881626",
              "quantity": 1
            },
            {
              "customer_identifier": "PNTS-NVY-SM",
              "sku_id": "ea957a79-9605-4948-b9f4-6c115d881627",
              "quantity": 2
            }
          ]
        }
      ],
      "shorts": [
        {
          "customer_identifier": "PNTS-NVY-LG",
          "sku_id": "ea957a79-9605-4948-b9f4-6c115d881626",
          "quantity": 1,
          "reason": "damage"
        },
        {
          "customer_identifier": "PNTS-NVY-SM",
          "sku_id": "ea957a79-9605-4948-b9f4-6c115d881627",
          "quantity": 1,
          "reason": "lost"
        }
      ]
    }
  ]
}

As a reminder, that is the payload that is going to be sent out from the MasonHub API to whatever endpoint you register to the ‘orderEvent’ callback.

Upgrades to the API Spec

OpenAPI 3.0 provides a mechanism for representing callbacks within the spec itself, but our rendering engine (the excellent Rebilly/Redoc) doesn’t yet support them effectively. Truth be told, the OpenAPI visual support is a little weak as well. We’ll be adding a new callback payload section in the API docs, so the specs and examples will be a little easier to navigate in the future.

Inventory Batch Processing

Lastly, we’ve aggregated our inventory changes to make them more reliable and less chatty. So issuing a “createAvailable” request to the data_factory should send one accurate picture of your inventory even though we are making multiple inventory changes in our ledger under the hood. If we still find that it’s too chatty, we can throttle the outbound messages with a parameter change on our end. Once we are hooked into the WMS with real-time inventory changes happening at high frequency, this will go a long way to keep the volume of sku snapshots feeding to Carbon’s endpoint to a reasonable and comfortable level.

Don’t be afraid to reach out to Chris or Andy with any questions.