Can't create fulfillment. Error 404

Topic summary

Error 404 occurred when creating a fulfillment via REST endpoint /orders/{order_id}/fulfillments.json. Omitting location_id returned a validation error; including it still failed. Root cause: these order-scoped fulfillment endpoints were removed in API version 2022-07.

Required approach (Fulfillment Orders flow):

  • Ensure app permissions for fulfillment orders are granted, based on location type (e.g., read/write_merchant_managed_fulfillment_orders or read/write_third_party_fulfillment_orders). Without these, fetching fulfillment_orders returns an empty array.
  • Retrieve the fulfillment_order_id: GET /admin/api/2023-01/orders/{order_id}/fulfillment_orders.json.
  • Create the fulfillment: POST /admin/api/2023-01/fulfillments.json with payload including line_items_by_fulfillment_order (the fulfillment_order_id) and tracking_info; notify_customer optional.

Notes:

  • FulfillmentOrder is created at order creation and represents fulfillable line items per location/provider; it’s required to create fulfillments in newer API versions.
  • Some docs may still reference deprecated endpoints, causing confusion.

Outcome: Issue resolved by switching to the Fulfillment/FulfillmentOrder APIs and enabling the correct permissions. Multiple participants confirmed success and shared code and doc links. Status: resolved.

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

Hello,

I try to create a fullfillment.

$url = 'https://ecowello.myshopify.com/admin/api/2023-01/orders/'.$order_id.'/fulfillments.json';
$data = [
    "fulfillment" => [
        "notify_customer" => true,
        "tracking_info" => [
            "number" => $tracking_id,
            "url" => "https://www.dhl.de/de/privatkunden/dhl-sendungsverfolgung.html?piececode=".$tracking_id,
            "company" => "DHL"],
        "location_id"=>70971195624
    ]
];

When I dont use the location-id, I get an error:

            [error] => location_id must be specified when creating fulfillments.

When i use it (the location-id is approved, I got it with

$url = 'https://ecowello.myshopify.com/admin/api/2023-01/locations.json';

)

I get no result from the api and an error 404.

Whats wrong?

with kind regards,

Kaus

I think API resource you are using is deprecated in that version.

See release notes from 2022-07

As of API version 2022-07, the following endpoints have been removed from the Fulfillment resource in the REST Admin API:

  • /orders/{order_id}/fulfillments.json
  • /orders/{order_id}/fulfillments/{fulfillment_id}.json
  • /orders/{order_id}/fulfillments/{fulfillment_id}/complete.json
  • /orders/{order_id}/fulfillments/{fulfillment_id}/open.json
  • /orders/{order_id}/fulfillments/{fulfillment_id}/cancel.json

Use the FulfillmentOrder resource instead.

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

Thanks,

but I need a fulfillment_order-id wich I dont have, and I cant create a fulfillment_order

When I try to get the existing fullfillment_orders, I get en empty array.

            [fulfillment_orders] => Array
                (
                ) 

Yes. That’s what I am saying.

I think you should be using this endpoint for creating fulfilments.

https://shopify.dev/docs/api/admin-rest/2023-01/resources/fulfillment#post-fulfillments

The one you are trying to call has been removed from api.

Yes. But to use this endpoint, I need a fulfillment_order_id.

I have none.

I want to post the tracking_id to an order

I putted the tracking-number manualy in an older order.

I found it in the API with this endpoint:

$url = 'https://ecowello.myshopify.com/admin/api/2023-01/orders/' . $order_id . '/fulfillments.json';

l

And the endpoints for fulfillment are still in the documentation for 2023-1

Ok, just a moment, I think I got it. Just a few Minutes…

Would be glad to see how you solved it.

I am facing similar issue. I try to use this api to create fulfilment. I use version 2022-07. But I don’t see this endpoint in documentation. So I guess what you and I have to do is get fulfilment order id cause it is created automatically during order creation. So you get it first and then use https://shopify.dev/docs/api/admin-rest/2023-01/resources/fulfillment#post-fulfillments

Ok, I’ve found it. Many thanks. You were right, and the failiure whre some missing rights…

In the shopify Backend you can set rigths for fulfilment_order.

$shopiyfy_api = new shopify_api();
$order_id = 'xxxxxxxxxxxx';
$result =$shopiyfy_api->getFullfillmentOrders($order_id); // tuts nach gesetzter berechtigung
$fulfillment_order_id = $result->result->fulfillment_orders[0]->id;
$shopiyfy_api->createFullfillment($order_id, $fulfillment_order_id, '00340434698785000666');
public function getFullfillmentOrders($order_id)
{
    $url = 'https://ecowello.myshopify.com/admin/api/2023-01/orders/' . $order_id . '/fulfillment_orders.json';
    $result = $this->curl_connect($url);
    return $result;
}
 public function createFullfillment($order_id, $fullfillment_order_id, $tracking_id)
    {

        $url = 'https://ecowello.myshopify.com/admin/api/2023-01/fulfillments.json';
        // $url = 'https://ecowello.myshopify.com/admin/api/2023-01/orders/fulfillments.json';
//                "location_id"=>xxxxxxxxxx
        $data = [
            "fulfillment" => [
                "message" => "Dat süht esu us, wie wenn dat Meldung erus jejange wör. Donnens misch anroofe!!!",
                "notify_customer" => true,
                "tracking_info" => [
                    "number" => $tracking_id,
                    "url" => "https://www.dhl.de/de/privatkunden/dhl-sendungsverfolgung.html?piececode=" . $tracking_id,
                    "company" => "DHL"],
                "line_items_by_fulfillment_order" => [
                    [
                        "fulfillment_order_id" => $fullfillment_order_id
                    ]
                ]
            ]
        ];
        $result = $this->curl_connect($url, $data);
    }
private function curl_connect($url, $postfields = false)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'X-Shopify-Access-Token: ' . $this->admin_api_access_token,
        'User-Agent: hlag himself',
        'Host: ' . $this->store
    ]);
    if ($postfields !== false) {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postfields));
    }
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $retval = new stdClass();
    $retval->result = json_decode(curl_exec($ch));
    $retval->url = curl_getinfo($ch)['url'];
    $retval->http_code = curl_getinfo($ch)['http_code'];
    return $retval;
}

But main solutions was to use different api for creating fulfilment right? Not just rights(permissions).

Both

And what permissions did you need to change? Cause I am receiving response that my client does not have access to the fulfillment order.

1 Like

Hello,

With the introduction of fulfillment orders there were also some new permissions created for working with them that are determined by the type of location involved, for example ‘read_merchant_managed_fulfillment_orders’ and ‘read_third_party_fulfillment_orders’.

If the appropriate permissions aren’t in place then the list of fulfillment_orders would return empty, as was shared earlier in this thread.

More information about these new permissions is available at [the Fulfillment Orders Migration Guide].

Thanks - this worked for me.

This is the relevant bit of the Shopify API docs. The code example helped me with writing the JSON blob. https://shopify.dev/docs/api/admin-rest/2023-07/resources/fulfillment#post-fulfillments

Cheers.