Shopify api fulfillment or order.save() not working in python

Topic summary

Issue: Creating a fulfillment via Python for an order without prior fulfillments returns ResourceNotFound on the REST 2023-01 endpoint, despite the fulfillments list being accessible (empty) in the admin URL.

What was tried: Building a shopify.Fulfillment with order_id, location_id, and order.line_items; setting tracking info and notify_customer; attempting fulfillment.save(), fulfillment.create(), and order.save() after appending to order.fulfillments. Token scopes were broadened to “all.”

Key guidance (Shopify Support):

  • Shopify has migrated to “fulfillment orders.” Creating a fulfillment now requires the 2023-01 API structure and fields.
  • Use the current fulfillment creation endpoint and payload that include line_items_by_fulfillment_order with fulfillment_order_id and fulfillment_order_line_items (id and quantity), plus tracking_info, notify_customer, and optional message.
  • Verify the app has all necessary scopes and validate input data; errors may stem from missing/incorrect fields or insufficient scopes.
  • Use an API client (Postman/Insomnia) to test requests and payload structure.

Status: No confirmed resolution. Next steps are to align payload with fulfillment orders, confirm scopes, and test via an API client. Code snippets and the example payload are central to understanding the fix.

Summarized with AI on January 31. AI used: gpt-5.

Hello, I am trying to create a fulfillment for shopify orders that doesn’t have fullfilment yet.

I have tried with fulfillment.save() by creating a shopify.Fulfillment object, also with fulfillment.create() and also with order.save() after adding the fulfillment object to the order.fulfillments list but nothing works.

Here is a part of my code in python :

fulfillment = shopify.Fulfillment({
‘order_id’: order.id,
‘location_id’: 71647264989,
‘line_items’: order.line_items

})
fulfillment.tracking_company = ‘Colissimo’
fulfillment.tracking_number = f’{num_suivi}’
fulfillment.tracking_url = ‘https://www.laposte.fr/outils/suivre-vos-envois
fulfillment.notify_customer = True
fulfillment.save()

and here is the error message I get :

ResourceNotFound: Not Found: https://‘myshop’.myshopify.com/admin/api/2023-01/orders/5067045699805/fulfillments.json

Actually I don’t understand where the problem comes from, I also updated my API autorisation for the token I am using and I selected all autorisations so it should be okay.

if I try to access the link from the error message, I see the fulfillments list which is empty.

If one of you have any idea to solve this problem it would be great.

1 Like

Hey @Romain_97 ,

I took a closer look at your post, and wanted to pass on a few things.

  • First, there is an extensive Fulfillment Apps overview doc to help determine which workflow(s) and APIs an app will need, scopes required, and other insights specific to any processes.
  • This guide on migrating to fulfillment orders also includes details around important changes to handling fulfillments via the API.

After reviewing those resources and confirming that the app has all necessary scopes, I’d take another look at the input data.

Using the fulfillment resource endpoint POST /orders/{order_id}/fulfillments.json and the current API version 2023-01, be sure to reference the API docs to confirm all required fields for creating a fulfillment on a fulfillment order.

Here is an example payload with required fields from recent changes highlighted:

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

{
  "fulfillment":{
    "message":"{EXAMPLE MESSAGE}",
    "notify_customer":false,
    "tracking_info":{
      "number":{
        SOME_TRACKING_NUMBER
      },
      "url":"{EXAMPLE_URL}",
      "company":"{EXAMPLE_COMPANY_NAME}"
    },
    "line_items_by_fulfillment_order":[
      {
        "fulfillment_order_id":{
          {
            fulfillment_order_id
          }
        },
        "fulfillment_order_line_items":[
          {
            "id":{
              {
                fulfillment_order.line_item.id
              }
            },
            "quantity":{
              SOME_QUANTITY
            }
          }
        ]
      }
    ]
  }
}

It is worth noting that while we aren’t currently able to share any example code or in this case python specific examples, the error message appears to be related to either the input or potentially a lack of necessary API scopes.

As a closing note, consider using an API client (Postman, Insomnia) to help debug and inform structure for any API calls, this can be invaluable for testing purposes. Hope that helps get the error sorted out on your end!

Cheers,
@awwdam - Shopify Developer Support