How to fulfill orders using REST API?

JianXiongWu
New Member
10 0 0

I need to fulfill orders using the REST API given the order_id. I started to retrieve the fulfillments associated with the order_id where order_id is 2185365291143

 

https://.../admin/api/2020-04/orders/2185365291143/fulfillments.json

I receive status code 200, and but the json body response is empty. I have verified that the order is unfullfilled.

{'fulfillments': []}

In the attached image, I have visualized what I really want to achieve (basically fulfill all the line items in an order)Capture.PNGCapture2.PNG

0 Likes
hassain
Shopify Staff (Retired)
Shopify Staff (Retired)
623 104 148

Hi @JianXiongWu ,

 

If you are using API version 2020-01 and higher, you can fulfill an order using the FulfillmentOrder and Fulfillment resources. Follow this document for more information on how to do this: https://shopify.dev/tutorials/manage-fulfillments-with-fulfillment-and-fulfillmentorder-resources 

 

If you are using API version 2019-10 and below, you can fulfill an order using the Fulfillment and the Location resources. You can follow this guide: https://shopify.dev/tutorials/manage-fulfillments-with-fulfillment-and-fulfillmentservice-resources

 

(Note these documents use GraphQL for its examples, but everything listed here you can do in REST as well)

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
hoggar
New Member
2 0 2

Here how you can Fulfill one complete order:

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillment#create-2021-0...

Fulfill all line items from 1 location:

POST /admin/api/2021-01/orders/{order_id}/fulfillments.json
{"fulfillment": { "location_id": 123456789 }}

 

This is the simplest way, you can also add various other options like tracking numbers. urls. etc ...

gsosa2703
New Member
1 0 0

Hi,

Thanks for the answer, i have a doubt, the location_id is a mandatory field?

0 Likes
irook
New Member
3 0 0

Does this work for you?  I've been trying this exact request to fulfill all items on an order, and I always get a blank response.  Other actions work, just not this one.

 

I've also tried to get a list of fulfillments, and it always comes up

 

{"fulfillment_orders":[]}

 

I think I need to create a fulfillment_order for the order first, but I cannot find out how to do this.

Any advice on how to create a fulfillment_order for an order? 

0 Likes
jmz
New Member
1 0 0

@irook 

I was looking for the same thing and finally figured it out. You need to query the fulfillment_orders endpoint [GET] for the order.

myshopify.com/admin/api/2021-07/orders/{order_id}/fulfillment_orders.json

{
    "fulfillment_orders": [
        {
            "id"null,
            "shop_id"null,
            "order_id"null,
            "assigned_location_id"null,
            "request_status""unsubmitted",
            "status""open",
            "supported_actions": [
                "create_fulfillment"
            ],
            "destination": {
                "id"null,
                "address1""null",
                "address2""",
                "city""null",
                "company""null",
                "country""null",
                "email""null",
                "first_name""null",
                "last_name""null",
                "phone""null",
                "province""null",
                "zip""null"
            },
            "line_items": [
                {
                    "id"null,
                    "shop_id"null,
                    "fulfillment_order_id"null,
                    "quantity"null,
                    "line_item_id"null,
                    "inventory_item_id"null,
                    "fulfillable_quantity"null,
                    "variant_id"null
                }
            ],
            "fulfill_at"null,
            "international_duties"null,
            "delivery_method"null,
            "assigned_location": {
                "address1""null",
                "address2"null,
                "city""null",
                "country_code""null",
                "location_id"null,
                "name""null",
                "phone""",
                "province""null",
                "zip""null"
            },
            "merchant_requests": []
        }
    ]

 

Though, seemingly counter-intuitive, the FulfillmentOrder appears to already exist, with just the presence of an unfulfilled order.

 

 

note: nulled out values for obvious reasons

0 Likes