Add multiple product variants to a selling plan
LegacyAPI v1 is the older API. It still works and is supported, but new integrations should use API v2. Migrating from v1 to v2
const url = 'https://app.stoqapp.com/api/v1/external/preorders/example/add_variant';const options = { method: 'POST', headers: {'X-Auth-Token': '<X-Auth-Token>', 'Content-Type': 'application/json'}, body: '{"shopify_variant_ids":[43900910010503,43900910010999]}'};
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/v1/external/preorders/example/add_variant \ --header 'Content-Type: application/json' \ --header 'X-Auth-Token: <X-Auth-Token>' \ --data '{ "shopify_variant_ids": [ 43900910010503, 43900910010999 ] }'Attach one or more Shopify product variants to a selling plan so they become available for preorder. Pass the variant IDs in shopify_variant_ids; any that are already attached are reported back under existing_variants with a 422. Returns the list of variant IDs that were newly added.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Selling plan ID
Header Parameters
Section titled “Header Parameters”API key for authentication
Request Bodyrequired
Section titled “Request Bodyrequired”object
Array of Shopify variant IDs to add
Example
{ "shopify_variant_ids": [ 43900910010503, 43900910010999 ]}Responses
Section titled “Responses”Variants added successfully
object
List of variant IDs that were added
Example
{ "success": true, "message": "2 variants added to selling plan", "variants_added": [ 43900910010503, 43900910010999 ]}Bad request - missing or invalid shopify_variant_ids
object
Example generated
{ "error": "example"}Unauthorized
Selling plan not found
Some variants already added or other error
object
List of variant IDs that were already added
Example generated
{ "error": "example", "existing_variants": [ 1 ]}Thanks for letting us know.
Still stuck? Ask Quinn or chat with support