How to fulfill shopify order via shopify API

shopify fulfillment order

How to fulfill Shopify order via Shopify API

If you recently migrated to the Shopify API version 2022-07 or planning to migrate to 2022-07 or higher from Shopify API version lower than 2022-04 you will notice that Shopify made breaking changes to the fulfillment order API.
If you are using your own fulfillment service, you can fulfill orders via Shopify API following the steps below.
Step 1:
Get List of fulfillment orders using the order Id:
4599844958385 = $shopify order id
Step 2:
If fulfillment order exists, loop through each fulfillment order and if status of the “request_status” is “unsubmitted”, you will submit fulfillment request:
https:// your-store-name,
5787678983 = $fulfillment order id
Post data: array('fulfillment_request'=>array('message'=>'In Transit',
'fulfillment_order_line_items'=>array()) );

Step 3:
If the request submission returns success, you need to accept the fulfillment request.
Request URL: https:// your-store-name,$fulfillment_order_id/fulfillment_request/accept.json
data: '{"fulfillment_request":{"message":"$custom_message."}}'

Step 4:
Final step, create fulfillment(s) for the fulfillment order.
Request URL: https://
{"fulfillment":{"message":"Package Shipped","notify_customer":"","tracking_info"
:{"url":":\/\/\/trackid","company":" Tracking company name","nu

Note: Data with $ sign is a variable and needs to be replaced with actual value.