Guide to Shopify 2023 API Fulfillment Process Changes

Published on Aug 11, 2024

By Liam Gallagher

#Shopify#API#Fulfillment
Man in Black Button Up Shirt Standing Beside Man in Gray Polo Shirt

Introduction

Shopify’s latest API update (2023-01) has introduced some changes to the fulfillment process, leaving many developers scratching their heads. If you’re encountering issues with the new fulfillment API, you’re not alone. This comprehensive guide will walk you through the process of creating fulfillments using the latest Shopify API, addressing common pitfalls and providing step-by-step solutions.

Understanding the New Fulfillment Process

The Three-Step Dance

The new fulfillment process in Shopify’s 2023-01 API involves a three-step approach:

  1. Retrieving order information
  2. Fetching the fulfillment order ID
  3. Creating the fulfillment

This might seem like extra work compared to previous versions, but it provides more flexibility and control over the fulfillment process.

Why the Change?

Shopify’s decision to introduce an intermediate step (fetching the fulfillment order ID) allows for more complex fulfillment scenarios. This change supports multi-location fulfillment and provides better tracking of fulfillment statuses across different stages of the order process.

Step 1: Retrieving Order Information

Fetching Orders

The first step in the fulfillment process is to retrieve the order information. Use the following API endpoint to get a list of orders:

GET /admin/api/2023-01/orders.json

Sample API Call

Here’s an example of how to make this API call using cURL:

curl --location --request GET 'https://your-store.myshopify.com/admin/api/2023-01/orders.json' 
--header 'X-Shopify-Access-Token: your_access_token'

Parsing the Response

The response will include an array of orders. Each order object will contain an id field, which you’ll need for the next step.

Step 2: Fetching the Fulfillment Order ID

The Missing Link

This step is crucial and is often the source of confusion for developers new to the 2023-01 API.

API Endpoint

Use the following endpoint to retrieve the fulfillment order ID:

GET /admin/api/2023-01/orders/{order_id}/fulfillment_orders.json

Sample API Call

Here’s how to make this call using cURL:

curl --location --request GET 'https://your-store.myshopify.com/admin/api/2023-01/orders/{order_id}/fulfillment_orders.json' 
--header 'X-Shopify-Access-Token: your_access_token'

Replace {order_id} with the actual order ID you obtained in Step 1.

Understanding the Response

The response will contain a fulfillment_orders array. Each object in this array will have an id field, which is the fulfillment order ID you need for the final step.

Step 3: Creating the Fulfillment

The Final Piece of the Puzzle

With the fulfillment order ID in hand, you can now create the fulfillment.

API Endpoint

Use this endpoint to create a fulfillment:

POST /admin/api/2023-01/fulfillments.json

Sample API Call

Here’s a cURL example for creating a fulfillment:

curl --location --request POST 'https://your-store.myshopify.com/admin/api/2023-01/fulfillments.json' 
--header 'X-Shopify-Access-Token: your_access_token' 
--header 'Content-Type: application/json' 
--data-raw '{
  "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": your_fulfillment_order_id
      }
    ]
  }
}'

Replace your_fulfillment_order_id with the ID you obtained in Step 2.

Interpreting the Response

A successful API call will return a 201 (Created) status code, and the order will be marked as fulfilled in Shopify.

Common Issues and Troubleshooting

“Not Found” Error

If you’re receiving a “Not Found” error, double-check that you’re using the correct IDs. Remember, the order ID, fulfillment order ID, and fulfillment ID are all different numbers.

Empty Response

An empty response when fetching fulfillment orders could indicate that the order is not ready for fulfillment or has already been fulfilled. Always check the order status before attempting to create a fulfillment.

Incorrect ID Usage

Ensure you’re using the fulfillment order ID, not the order ID, when creating the fulfillment. These are different numbers and using the wrong one will result in errors.

Best Practices for Working with Shopify’s Fulfillment API

Implement Error Handling

Always implement robust error handling in your API calls. This will help you quickly identify and resolve issues.

Use Shopify’s Official Documentation

While this guide provides a comprehensive overview, always refer to Shopify’s official documentation for the most up-to-date information:

https://shopify.dev/api/admin-rest/2023-01/resources/fulfillment

Test in Development Environment

Before implementing changes in a production environment, always test your API calls in a development store to avoid potential issues with live orders.

By following this guide, you should now have a clear understanding of how to work with Shopify’s 2023-01 API for fulfillments. Remember, while the process may seem more complex at first, it provides greater flexibility and control over the fulfillment process, ultimately leading to a more robust e-commerce system.

Take Our Quick Quiz:

Which primary product image do you think has the highest conversion rate?