Update Track Quantity via API

Hi,

We are developing an extension to our shipping application that sets a variant/product to out of stock when it is flagged as not available by our warehouse staff.

Currently our products are set to “Track Quantity” = false in the SHopify admin. When we set items to OOS we generally tick the box Track Quantity manually, and then add a 0 or negative stock level for our warehouses, of which we have three in Shopify.

The question I have is using the API what is the best method to toggle the variant/product as Out of Stock, and back to in stock when needed?