How do I create a shipment via REST API?

It seems that you are not passing any items. While creating shipment you must mark atleast one item as shipped.

{
    "entity": {
        "order_id": 8,
        "items": [{
            "order_item_id": 123,
            "qty": 1
        }]
    }
}

An extra note that you can only pass items as of now. Comments and tracks are not working due a Magento bug. Have a look at git issue.


If you are shipping all items in the order, there is no need to actually include the items:

{

  "tracks": [
    {
      "track_number": "1Y-9876543210",
      "title": "Custom",
      "carrier_code": "SomeCarrierCode"
    }
  ]
}

As long as you have the Magento order ID in the URL rest/V1/order/10/ship, this will work. Plus, the carrier_code can be anything if you haven't got real carriers setup...

This took me hours to find out, as Magento's documentation and API is shocking!

Tags:

Rest

Api

Magento2