How to mark orders as fulfilled with the FulfillmentOrders API (REST)

How to mark orders as fulfilled with the FulfillmentOrders API (REST)

Ashfaq_
Shopify Partner
5 0 4

Hey everyone, I have been trying to get fulfillments to work.
I have the all the scopes mentioned by Shopify write_merchant_managed_fulfillment_orders,write_third_party_fulfillment_orders,write_assigned_fulfillment_orders,write_fulfillments.

How Do i fulfill items as complete using REST ? I have tried both Fulfillment API and FulfillmentOrders API

The APIs that I have tried and the responses I have receieved
POST request /admin/api/2021-10/fulfillments.json
Bad Request 400
POST request admin/api/2021-10/orders/450789469/fulfillments.json
Bad Request 400
POST request /admin/api/2021-10/orders/450789469/fulfillments/255858046/complete.json
Bad Request 400

POST request admin/api/2021-10/fulfillment_orders/1046000782/close.json
Bad Request 400
POST request /admin/api/2021-10/fulfillment_orders/1046000785/open.json
Bad Request 400

The parameters I am sending is in accordance with the cUrl request as mentioned in https://shopify.dev/api/admin-rest/2022-07/resources/fulfillmentorder


After checking all of this I went to the shopify community forum to find the method, but I could see similar questions which had discussions going and people still trying to figure the solution.

Thread 1: https://community.shopify.com/c/shopify-apis-and-sdks/struggling-with-fulfillment-orders/m-p/1235175

Thread 2: https://community.shopify.com/c/shopify-apis-and-sdks/create-fulfillment-order-problem/m-p/1670182

Thread 3: https://community.shopify.com/c/shopify-apis-and-sdks/create-fulfillment-order-problem/m-p/1670182


Please let me know if there's any way I can improve

Replies 2 (2)

RobZone
Shopify Staff
76 10 22

A post to /admin/api/2022-10/fulfillments.json is the correct API.  I suspect your request body does not quite match the documentation.  If you want to add it to the thread, I can try to help figure out what is going on.

 

https://shopify.dev/api/admin-rest/2022-10/resources/fulfillment#post-fulfillments

To learn more visit the Shopify Help Center or the Community Blog.

deparagon
Shopify Partner
8 0 1

You need to upgrade your API version to 2022-07 or better still 2022-10.

I assume you have fulfillment service and all the inventories are in the location created by your fulfillment service.

Let's say you want to fulfill a shopify order with Order Id:  4534463334556

1) Send get request to 

https://your-store-name.myshopify.com/admin/api/2022-10/orders/4534463334556/fulfillment_orders.json

You will get list of fulfillment orders for the shopify order 4534463334556 

 

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,myshopify.com/admin/api/2022-10/fulfillment_orders/5787678983/fulfillment_request.json

5787678983 = $fulfillment_order_id

Post Data: 

array('fulfillment_request'=>array('message'=>$message,

        'fulfillment_order_line_items'=>array()) );

Note: Post data has to be in json format and text with $ sign needs to be replaced with actual value.

 

 

 

3) 

If the request submission returns success, you need to accept the fulfillment request.

Post Request URL: https:// your-store-name,myshopify.com/admin/api/2022-10/fulfillment_orders/$fulfillment_order_id/fulfillment_request/accept.json

Post Data:  

'{"fulfillment_request":{"message":"$custom_message."}}'

 

4) Finally create fulfillment(s) for the fulfillment order.

Post Request URL: https:// your-store-name.myshopify.com /admin/api/2022-07/fulfillments.json

Post data Json: 

{"fulfillment":{"message":"Package Shipped","notify_customer":"","tracking_info"
:{"url":":\/\/mytrackingurl.com\/trackid","company":" Tracking company name","nu
mber":""},"line_items_by_fulfillment_order":[{"fulfillment_order_id":null,"fulfi
llment_order_line_items":[]}]}}

If all the details are good, the order will automatically be fulfilled.

PHP developer with many years of experience in web development industry.
Senior developer @ Taobao Dropshipping App