Cookies setting

Cookies help us enhance your experience on our site by storing information about your preferences and interactions. You can customize your cookie settings by choosing which cookies to allow. Please note that disabling certain cookies might impact the functionality and features of our services, such as personalized content and suggestions. Cookie Policy

Cookie Policy
Essential cookies

These cookies are strictly necessary for the site to work and may not be disabled.

Information
Always enabled
Advertising cookies

Advertising cookies deliver ads relevant to your interests, limit ad frequency, and measure ad effectiveness.

Information
Analytics cookies

Analytics cookies collect information and report website usage statistics without personally identifying individual visitors to Google.

Information
mageplaza.com

How to Create a Shipment via REST API

Vinh Jacker | 12-18-2024

How to Create a Shipment via REST API

As a robust, scalable and multi-featured e-commerce platform, Magento 2 allows users to create shipments of an order using API. This is a useful feature that helps you create shipments easily and quickly.

In this article, I will instruct you to create a shipment with Magento 2 API through the below steps:

Create A Shipment With Magento 2 API

To create a shipment, initially, you have to get the order_item_id of each item to be shipped. In this post, assuming that you need to create the shipments for the Sprite Yoga Companion Kit and the Radiant Tee-M-Orange. Because the Sprite Yoga Companion Kit is a bundle product, only the top-level order_item_id (5) needs to be included. The Radiant Tee-M-Orange has the order_item_id as 3.

Note:

  • If you want to create a partial shipment, define only those order_item_ids that are to be shipped now.
  • The status of an order will be automatically changed to Complete if the call is successful on a full shipment.

Endpoint

POST <host>/rest/<store_code>/V1/order/3/ship where 3 is the order id.

Headers

Content-Type application/json

Authorization Bearer <administrator token>

Payload

The tracks array optionally allows you to include one or more tracking numbers for the shipment.

The Code Sample

{
  "items": [
    {
      "order_item_id": 3,
      "qty": 1
    },
    {
      "order_item_id": 5,
      "qty": 1
    },
    {
      "order_item_id": 11,
      "qty": 1
    }
  ],
  "tracks": [
    {
      "track_number": "1Y-9876543210",
      "title": "United Parcel Service",
      "carrier_code": "ups"
    }
  ]
}

Response

A shipment ID, such as 3.

Verify The Results

  • Access your admin panel.
  • Navigate to Sales > Shipments, here you will see the shipment shown in the grid.
  • Navigate to Sales > Orders, here you will see the status of the order is Complete.

Conclusion

Above are the detailed instruction for creating a shipment with Magento 2 API. Hopefully, this post is helpful for you. If you have any questions or want to discuss something related to this post, don’t hesitate to leave a comment below!

x
    Jacker

    With over a decade of experience crafting innovative tech solutions for ecommerce businesses built on Magento, Jacker is the mastermind behind our secure and well-functioned extensions. With his expertise in building user-friendly interfaces and robust back-end systems, Mageplaza was able to deliver exceptional Magento solutions and services for over 122K+ customers around the world.



    Related Post

    Website Support
    & Maintenance Services

    Make sure your store is not only in good shape but also thriving with a professional team yet at an affordable price.

    Get Started
    mageplaza services