Solved

Need Help: Creating Fulfillment Orders via API

jintoag
Visitor
2 0 0

Is it possible to create a fulfillment order using the Shopify REST API in the latest 2023-01 version? I've reviewed the documentation and noticed that fulfillment orders are automatically created when an order is created, but I want to create a fulfillment order using the API. I was able to create a fulfillment using the 2022-04 version without using a fulfillment order, but I want to know if there is a way to create a fulfillment order using the API in the latest version. Any guidance or resources would be greatly appreciated. Thank you!

 

https://shopify.dev/docs/api/admin-rest/2023-01/resources/fulfillmentorder#top

Accepted Solution (1)
garyrgilbert
Shopify Partner
388 40 159

This is an accepted solution.

Hi Jinto,

 

its unlikely that a correct get to the fulfillment_orders.json enpoint will result in an empty array even if all fulfillment orders have been fulfilled. I have tested this extensively on development shops with unfulfilled, partially fuliflled and fulfilled orders and it always returns an array of fuflillment_orders.  So I suspect there is a problem in your path/rights somewhere.

 

right the new fulfillment endpoint as of 2022-10 takes a different json object as input please refer to the documentation to find out which data to post to the endpoint.

 

Regards,

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution

View solution in original post

Replies 10 (10)

garyrgilbert
Shopify Partner
388 40 159

Hi There,

 

I think you are a bit confused.  A fulfillmentorder is not the same thing as a fulfillment.

 

A fulfillment order is generally automatically created, this is what assigns the order to a particular fulfillment location or service.

 

What you want to do is get the fulfillment_orders for a particular order and then generally fulfill those for the location you are interested in.

 

see this post I wrote.

 

Cheers

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
jintoag
Visitor
2 0 0

Thank you for reaching out and clarifying the difference between fulfillment orders and fulfillments. I understand that fulfillment orders are automatically created to assign an order to a specific fulfillment location or service. However, for a certain order I am testing, the fulfillment order is not created automatically.

 

I attempted to retrieve fulfillment orders for this specific order using the API POST /admin/api/2023-01/orders/{order_id}/fulfillment_orders.json , but the result was an empty array.

 

What I want is to create a fulfillment for this specific order using the Admin REST API. Previously, I was using an older API, but now I am in the process of migrating to the latest version. The ability to create a fulfillment using the API is a new feature that I want to implement.

 

Thank you.

Jinto A G

garyrgilbert
Shopify Partner
388 40 159

This is an accepted solution.

Hi Jinto,

 

its unlikely that a correct get to the fulfillment_orders.json enpoint will result in an empty array even if all fulfillment orders have been fulfilled. I have tested this extensively on development shops with unfulfilled, partially fuliflled and fulfilled orders and it always returns an array of fuflillment_orders.  So I suspect there is a problem in your path/rights somewhere.

 

right the new fulfillment endpoint as of 2022-10 takes a different json object as input please refer to the documentation to find out which data to post to the endpoint.

 

Regards,

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution

EcomGraduates
Shopify Partner
588 48 77

it is possible to create a fulfillment order using the Shopify REST API in the latest 2023-01 version. You can use the "FulfillmentOrder" resource to create a fulfillment order.

To create a fulfillment order using the API, you can make a POST request to the "/admin/api/2023-01/fulfillment_orders.json" endpoint, with the required parameters for the fulfillment order. The minimum required parameters are "order_id", "location_id", and "line_items". You can also include other parameters such as "tracking_number" and "notify_customer".

 

Here is an example JSON payload for creating a fulfillment order:

{
  "fulfillment_order": {
    "order_id": 123456789,
    "location_id": 987654321,
    "line_items": [
      {
        "id": 123,
        "quantity": 2
      }
    ],
    "tracking_number": "123456789",
    "notify_customer": true
  }
}

 

garyrgilbert
Shopify Partner
388 40 159

@EcomGraduates I think you are mistaken, at least I am not familiar with any fulfillmentorder resource that accepts that structure to fulfill an order.

 

In my experience in order to fulfill an order with the 2023-01 rest api fulfillment resource the following structure is required.

 

{
    "fulfillment": {
        "message": "The package was shipped this morning.",
        "notify_customer": false,
        "tracking_info": {
            "number": 1562678,
            "url": "https://www.my-shipping-company.com",
            "company": "my-shipping-company"
        },
        "line_items_by_fulfillment_order": [
            {
                "fulfillment_order_id": 1046000784,
                "fulfillment_order_line_items": [
                    {
                        "id": 1058737493,
                        "quantity": 1
                    }
                ]
            }
        ]
    }
}

 

regards,

 

Gary Gilbert

 

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
svmovingit
Visitor
2 0 3

@garyrgilbert 

This looks correct to me comparing to the documentation.

But now I have an webshop that doesn't create fulfillment orders automaticly.

We don't have an fullfillment_order_id

If we request 2023-01/orders/***/fulfillment_orders.json

 

We get:

{
    "fulfillment_orders": []
}

 

How can I fullfill this order?

 

 

 

fabrictrove
Visitor
2 0 0

You're not alone... I'm trying to write a simple scanning mobile app (with react native) that would mark my orders as shipped and record the tracking number... But no fulfillments or fulfillment_orders are created when a customer places an order. So needlessly complicated...

svmovingit
Visitor
2 0 3

@EcomGraduates 

This does't seem to work in 2023-1: 

 406: Not acceptable

fabrictrove
Visitor
2 0 0

I just came across this: make sure that your app has these scopes:

read_merchant_managed_fulfillment_orders,write_merchant_managed_fulfillment_orders

garyrgilbert
Shopify Partner
388 40 159

yes, you need those scopes in order to read the fulfillment orders. Unlike other endpoints in shopify if you dont have the correct scope assigned you wont get an error but an empty result!

 

@ShopifyDevSup could you pass this along to the developers we should really be getting a warning or error when making a request to fulfillment_orders without having the appropriate scopes assigned instead of an empty resultset. It's really confusing when everywhere else we get an error but here not.

 

Cheers,

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution