Jump to content

Getting Inventory from Orders API response

Recommended Posts

I looking for a way to retrieve inventory data related to an order.

I have a webhook setup in Stripe, to get notifications when orders are placed. Stripe passes along the Squarespace


, so I'm able to use the Orders API to get data about the order. The Inventory API, though, expects a


, and it doesn't seem like that is included in the Orders API response. The only inventory-related values I'm seeing in the order response are




, but neither of those work as values to send to the Inventory ID.

Is there a way to do this, other than requesting the entire inventory from the API and paging through it until I find the correct SKU?


Link to comment
  • 4 months later...
  • Replies 1
  • Views 1.3k
  • Created
  • Last Reply

Hey farski,

I've been able to tackle this issue through API automation. To extract the Inventory ID for the specific products ordered, you need to pull the Order from the Order API and parse the result, specifically (per order row), look at '{lineItems}{<index>}{id}'. I use Python to loop through the products and flatten the structure before import into our backend system, so i do not use the <index> field, I just throw it into a loop that hands me the list of items and I parse the fields I want.

Once you have the lineItem ID, you can send that through the Inventory API, and you should get the inventory record you are looking for.

Alternatively, as a business process, as I upload or create new inventory on the site, I do a full pull from the Inventory API and then match the internal DB SKU to the SKU connected to the VariantId. I then retain this and when I want to query the inventory item (or change quantity, and hopefully price soon), I can easily extract the ID from my db and submit the right call.

Hope that helps.

Link to comment


This topic is now archived and is closed to further replies.

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.