Design the preorder widget with an AI agent
design_preorder: templates, preview, draft, apply and rollback for STOQ's storefront preorder widget, with server-side cleaning of agent HTML and CSS.
BetaAPI v2 is in public beta: endpoints, fields and behaviour can change before general availability. See the changelog
Last updated
design_preorder is an MCP store tool that lets an agent restyle the preorder widget STOQ’s app embed draws on the product page: button and badge colours, the disclaimer box (HTML), the ship-date and limited-quantity lines, the progress bar, the countdown, the payment options, and CSS for STOQ’s own elements. It writes only settings the widget already reads, plus one block of the shop’s custom CSS. It never writes theme code; for Liquid sections or headless code use design_theme.
It is enabled per shop (the design_preorder feature flag). The same actions are in the API v2 catalog under /preorders/design and /preorders/offers/:id/design.
The flow
Section titled “The flow”action |
API v2 | What it does |
|---|---|---|
templates |
GET /preorders/design/templates |
The guide, the components (CSS classes and the fields that drive each one), the {{ placeholders }} the storefront fills, and starting templates: minimal_, brand_, deposit_, countdown_, dark, rtl, limited_. |
preview |
POST /preorders/offers/:id/design/preview |
Checks and cleans a design, lists the changes against what is live, and returns preview_. Writes nothing. |
save_ |
POST /preorders/offers/:id/design/drafts |
The same checks, saved as a draft; returns draft_. |
apply |
POST /preorders/offers/:id/design/drafts/:draft_ |
Writes the draft, all or nothing. Live on the storefront after this. |
rollback |
POST /preorders/offers/:id/design/rollback |
Restores exactly what the last apply replaced. Call it again to undo the one before. Pass design_ so a retry is safe: a design already rolled back is left alone (already_), and one that is no longer the live design is refused with conflict. Refuses with conflict if those settings changed since apply, unless force: true. |
history |
GET /preorders/offers/:id/design |
The applied design, the design CSS block and recent drafts. |
A design
Section titled “A design”{ "widget": { "button": { "custom_colors_enabled": true, "background_color": "#1a73e8", "text_color": "#ffffff" }, "badge": { "show_badge": true, "badge_text": "Preorder", "background_color": "#1a73e8" }, "disclaimer": { "show_disclaimer": true, "disclaimer_text": "<strong>Reserve yours with a deposit.</strong><br>Pay the rest when it ships." } }, "shipping": { "timeline": { "show_shipping_text": true, "shipping_text": "Ships {{ date }}" } }, "css": ".restock-rocket-preorder-badge { border-radius: 999px !important; }"}Only the fields you send change. The sections are widget (button, disclaimer, badge), countdown, limits (display_style, limit_text, show_icons, progress_bar), shipping.timeline and payments.show_payment_widget, each checked by the same rules as its section PATCH. Dates, prices, limits and terms are not design fields: change them with their own actions. Send locale to write the texts in another language.
What is cleaned or refused
Section titled “What is cleaned or refused”- HTML fields (
disclaimer_text,limit_text,shipping_text) keep formatting tags only:p br span strong b em i u s small sub sup mark abbr ul ol li div a bdi bdo time, withclass dir lang title style(andhref target relon links). Links may go to the shop’s own pages,mailto:ortel:. Scripts, event handlers,javascript:anddata:URLs, images, iframes, SVG, forms, comments and outside links are removed, and the response lists what was removed. Plain-text fields (button, badge, countdown and progress-bar texts) lose all markup. Limits: 2,000 characters for HTML, 200 for text. - CSS is refused, not rewritten. Each selector must end on a STOQ element (
.restock-rocket-*,.preorder-*,.countdown-*,.stoq-*). Only plain rules, optionally inside one@mediablock, with colour, background, border, spacing, font, text and flex/grid layout properties. Nothing that could hide, move or cover the add-to-cart, Preorder or checkout button is allowed: nodisplay: none,opacity,visibility,position,z-index, offsets,transform,filter,clip,mask,pointer-events, negative margins,overflowormax-height, and no font size under 10px. Nourl(),var(),@import,@font-faceor@keyframes. Limits: 8,000 characters and 60 rules.
The design CSS sits in its own block of the shop’s custom CSS (/* stoq-design:preorder start */ … end), so the merchant’s own rules and back-in-stock styling are never touched, and it applies to every preorder offer in the shop. The storefront sets the widget’s colours inline from the settings, so use the colour settings where they exist and add !important to CSS that must win over them.
Thanks for letting us know.
Still stuck? Ask Quinn or chat with support