Connecting Draft Orders API/Orders API for Fetching Order IDs

I am currently working on integrating the Draft Orders API and the Orders API into my application. While I have successfully been able to fetch draft orders using the Draft Orders API, I’m encountering a challenge in obtaining the corresponding order IDs via the Orders API.

Hi Uplanalytics,

The Draft Orders API and the Orders API are separate, so there isn’t a direct way to obtain the corresponding order ID from a draft order via the Orders API. However, when you complete a draft order using the Draft Orders API, the response includes the order ID for the completed order.

Here is an example of how to complete a draft order using the Shopify API:

POST /admin/api/2023-04/draft_orders/#{draft_order_id}/complete.json

This will mark the draft order as completed and create an order. The response will look like this:

{
“draft_order”: {
“id”: 317176490,
“order_id”: 317176491,

}
}

In the response, order_id is the ID of the order that was just created. You can then use this order ID with the Orders API to obtain any additional information you need about the order.

Make sure you replace #{draft_order_id} with the actual draft order ID you want to complete.

Hope this helps!

1 Like