Skip to content

Build a preorder offer from a description

Worked recipe: describe a preorder offer in plain words, have plan_offer turn it into the ordered API calls, run them, and verify the offer and its selling plan. Every call, a worked plan, and how to check it.

Last updated

For: merchants and agencies who describe an offer in words (“a 30% deposit, the rest when it ships, ships 1 March, two per order”) and want an AI agent to build it correctly the first time.

Goal: a preorder offer with the right variants, deposit, balance, ship date and limits, created in the safe order, switched on last, and checked against the selling plan Shopify holds.

plan_offer only plans. It reads no store data and creates nothing. It returns the calls that build the offer, already ordered and checked against the API, and you run them.

  • Credentials: an MCP client signed in to the store with OAuth (see MCP), or the store’s API key.
  • Variant ids: find them first with a product search; don’t guess them. Shopify admin URLs carry the numeric id, and plan_offer accepts it for collections and markets.
  • Questions first: if the request leaves out something the offer can’t do without (which products, how big the deposit, which ship date), ask the merchant before you call plan_offer.
  • What the API can’t do: a limit per customer across orders, and a cap on total units sold for the whole offer. The plan’s warnings say so; tell the merchant, and don’t promise them.
{
"tool": "plan_offer",
"arguments": {
"offer": {
"name": "Winter Drop",
"products": { "variant_ids": ["gid://shopify/ProductVariant/43900910010503", "gid://shopify/ProductVariant/43900910043271"] },
"payment": { "mode": "partial", "deposit_percent": 30, "balance_on_fulfillment": true },
"shipping": { "delivery": "date", "date": "2027-03-01", "text": "Ships 1 March" },
"limits": { "max_per_order": 2 },
"launch": { "enable": true }
}
}
}

Every section is optional; leave out what the merchant didn’t ask for, including inventory. Add inventory.continue_selling: true only when the merchant has sold-out variants and agrees, because it changes Shopify’s inventory policy for the attached variants. The sections are products, inventory, payment (including discount), shipping, limits, markets, widget, checkout, schedule, launch and batches. A request the API can’t build, such as payment.mode: "full" with a deposit, comes back as an error that names the field. Fix it and call again.

{
"summary": "10 calls build \"Winter Drop\". Run them in order with execute_write / execute_read …",
"steps": [
{ "step": 1, "tool": "execute_write", "arguments": { "method": "POST", "path": "/preorders/offers", "params": { "name": "Winter Drop" } }, "purpose": "Create the offer. Its id replaces :id in every later step." },
{ "step": 2, "tool": "execute_write", "arguments": { "method": "POST", "path": "/preorders/offers/:id/disable" }, "purpose": "Pause the new offer (offers are live as soon as they are created) while it is set up." },
"…"
],
"warnings": ["inventory.continue_selling changes Shopify's inventory policy of the attached variants …", "limits.max_per_order caps one order only: a customer can place several orders."],
"unsupported": [],
"script": "#!/usr/bin/env bash …"
}

Read warnings and unsupported to the merchant before you run anything. The order is fixed by the tool: a new offer is live the moment it exists, so it is paused straight after it is created, and it is turned on last; inventory rules go in before variants are attached; the payment options come before the deposit and balance; attaching variants runs as a background job, so the plan waits for it before turning the offer on. script is the same plan as a curl script for the store’s API key.

Run each step with the tool and arguments the plan gives, adding a fresh idempotency_key to each write. Replace :id with the id the first step returns, and :job_id with the job.job_id the product step returns. For this offer the plan’s calls are:

{ "tool": "execute_write", "arguments": { "method": "POST", "path": "/preorders/offers", "params": { "name": "Winter Drop" }, "idempotency_key": "<new uuid>" } }
{ "tool": "execute_write", "arguments": { "method": "POST", "path": "/preorders/offers/<offer_id>/disable", "idempotency_key": "<new uuid>" } }
{ "tool": "execute_write", "arguments": { "method": "POST", "path": "/preorders/offers/<offer_id>/products/add_variants", "params": { "shopify_variant_ids": ["gid://shopify/ProductVariant/43900910010503", "gid://shopify/ProductVariant/43900910043271"] }, "idempotency_key": "<new uuid>" } }
{ "tool": "execute_write", "arguments": { "method": "PATCH", "path": "/preorders/offers/<offer_id>/payments", "params": { "options_offered": "partial" }, "idempotency_key": "<new uuid>" } }
{ "tool": "execute_write", "arguments": { "method": "PATCH", "path": "/preorders/offers/<offer_id>/payments", "params": { "partial": { "checkout_charge": { "charge_type": "percentage", "charge_amount": 30 } }, "collection_schedule": "on_fulfillment" }, "idempotency_key": "<new uuid>" } }
{ "tool": "execute_write", "arguments": { "method": "PATCH", "path": "/preorders/offers/<offer_id>/shipping", "params": { "ships_at": "2027-03-01", "timeline": { "show_shipping_text": true, "shipping_text": "Ships 1 March" } }, "idempotency_key": "<new uuid>" } }
{ "tool": "execute_write", "arguments": { "method": "PATCH", "path": "/preorders/offers/<offer_id>/limits", "params": { "order_quantity": { "maximum": 2 } }, "idempotency_key": "<new uuid>" } }

Then wait for the attach job, and only when its status is completed turn the offer on. If it is failed, stop and tell the merchant.

{ "tool": "execute_read", "arguments": { "method": "GET", "path": "/preorders/product_variants/jobs/<job_id>" } }
{ "tool": "execute_write", "arguments": { "method": "POST", "path": "/preorders/offers/<offer_id>/enable", "idempotency_key": "<new uuid>" } }

A 409 with preflight_issues on the product step means some variants are on another offer or can’t take preorders as they are. Ask the merchant which fix they want, then resend with the resolve keys (see step 3 of Launch a preorder offer from a product list). A schedule start turns the offer on by itself, so the plan leaves enable out and says so in its warnings.

{ "tool": "execute_read", "arguments": { "method": "GET", "path": "/preorders/offers/<offer_id>" } }

This is the plan’s last step, and part of the job: run it, compare the offer with what the merchant asked for, and report what you read. Don’t say the offer is built before you have read it back.

Code What happened What to do
auth_required, auth_invalid No credential, or not a current one Reconnect the MCP client or send the store’s API key
invalid_params A field failed the schema Fix the field named in details[].path and resend that step
preflight_issues Some variants can’t be added as they are Ask the merchant, then resend with the resolve keys
plan_required A deposit, schedule, batches or collection selection needs a paid plan; that step saved nothing Tell the merchant; leave the paid part out or ask them to upgrade
conflict The attach job is still running, or the offer’s state doesn’t allow the step Wait for the job, then retry the step
rate_limited The key used its points for this minute Wait retry_after seconds

If a run stops partway, read the offer (step 4) before you retry. It stays paused until the last step, so a half-built offer is never live.

  1. Read the offer: availability.current_status is live (or off if the merchant asked to review first), the deposit is 30%, shipping.ships_at is 2027-03-01 and the per-order maximum is 2.

  2. List its variants and compare the count with the list you sent:

    { "tool": "execute_read", "arguments": { "method": "GET", "path": "/preorders/offers/<offer_id>/products/variants", "params": { "per_page": 100 } } }
  3. Verify the selling plan: ask how a shopper sees one of the variants. status: "live" means the offer applies to it:

    { "tool": "execute_read", "arguments": { "method": "GET", "path": "/preorders/product_variants/availability", "params": { "country": "US", "shopify_variant_ids": "43900910010503" } } }

    STOQ publishes the offer to Shopify as a selling plan in the background, so allow a minute. The storefront data on the variant (see Preorder badge, button and notify-me on a headless storefront) then lists the selling plan with the deposit and the ship date.

  4. Tell the merchant what the plan’s warnings said, in particular that max_per_order limits one order, not a customer.

Was this page helpful?

Still stuck? Ask Quinn or chat with support