Bulk Toggle Inventory Policy
BetaAPI v2 is in public beta: endpoints, fields and behaviour can change before general availability. See the changelog
const url = 'https://app.stoqapp.com/api/v2/external/preorders/products/bulk_toggle_inventory_policy';const options = { method: 'POST', headers: {'X-Auth-Token': '<X-Auth-Token>', 'Content-Type': 'application/json'}, body: '{"policy":"CONTINUE","shopify_variant_ids":["45000000001"],"skip_quantity_limited":5}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.stoqapp.com/api/v2/external/preorders/products/bulk_toggle_inventory_policy \ --header 'Content-Type: application/json' \ --header 'X-Auth-Token: <X-Auth-Token>' \ --data '{ "policy": "CONTINUE", "shopify_variant_ids": [ "45000000001" ], "skip_quantity_limited": 5 }'Turn ‘Continue selling when out of stock’ on (CONTINUE) or off (DENY) for variants on the store-wide Preorders > Products tab, whatever offers they are in.
Note: shopify_variant_ids are up to 100 Shopify variant gids, as the tab selects them a page at a time; ones STOQ has no row for come back under skipped_shopify_variant_ids. With CONTINUE, variants that have reached their quantity limit on any offer are left out (skipped_quantity_limit_shopify_variant_ids), as the tab’s ‘Skip products that have reached their quantity limit’ (checked by default) does; skip_quantity_limited: false includes them. Fails with 422 quantity_limit_reached when every variant is left out. Before turning it off, GET /preorders/products/inventory_policy_conflicts names the other offers that need it on. Finishes before the response. For one offer’s variants use /preorders/offers/:id/products/bulk_toggle_inventory_policy.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Example
{ "policy": "CONTINUE", "shopify_variant_ids": [ "45000000001" ], "skip_quantity_limited": 5}Responses
Section titled “Responses”Success — the updated resource.
object
Example generated
{}Accepted — async/bulk work was queued. Poll the returned job.
Returned for async/bulk work — poll the job until it reaches a terminal state.
object
Example
{ "job_id": "job_a1b2c3", "status_url": "/api/v2/external/jobs/job_a1b2c3"}Missing or invalid X-Auth-Token.
Error envelope returned by every failed request.
object
Example
{ "errors": [ "Unauthorized" ]}The request failed validation.
Error envelope returned by every failed request.
object
Example
{ "errors": [ "name is required" ]}Rate limited — cost-weighted per token (read 1, write 2; 360 points / 60s). Check Retry-After.
Error envelope returned by every failed request.
object
Example
{ "errors": [ "Rate limit exceeded" ]}Thanks for letting us know.
Still stuck? Ask Quinn or chat with support