Design the notify-me widget with an AI agent
design_bis: templates, preview, draft, apply and rollback for STOQ's back-in-stock widget and per-product notify-me rules, 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_bis is an MCP store tool that lets an agent design the back-in-stock (notify-me) widget STOQ’s app embed draws on sold-out products: the notify-me button, the signup form (its texts in any shop language, colours, which fields it asks for, inline or popup, SMS and email consent wording), the signup confirmation, CSS for STOQ’s own elements, and per-product rules. It writes only settings the widget already reads, product rows the same way PATCH /back_in_stock/products does, and one block of the shop’s custom CSS. It never writes theme code (use design_theme), and notification email or SMS content is not part of a design.
It is enabled per shop (the design_bis feature flag) and has the same actions as design_preorder. They are also in the API v2 catalog under /back_in_stock/design.
The flow
Section titled “The flow”action |
API v2 | What it does |
|---|---|---|
templates |
GET /back_ |
The guide, the components (classes and ids and the fields that drive each one), the per-product fields, starting templates (minimal, theme_, inline_, sms_, dark, rtl, restock_, bold_) and the shop’s own widget templates. |
preview |
POST /back_ |
Checks and cleans a design, resolves its product groups, lists the changes against what is live, what the per-product choices do to automatic alerts (alerts), and returns preview_. Writes nothing. |
save_ |
POST /back_ |
The same checks, saved as a draft; returns draft_. A collection is expanded to its products here. |
apply |
POST /back_ |
Writes the draft, all or nothing. Live on the storefront after this. |
rollback |
POST /back_ |
Restores exactly what the last apply replaced: widget settings, the design CSS block, and every product row it changed (visibility, restock note, template, automatic alerts). Deletes the widget templates it created. 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 any of those changed since apply, unless force: true. |
history |
GET /back_ |
The applied design, the design CSS block and recent drafts. |
A design
Section titled “A design”{ "button": { "text": "Notify me", "background_color": "#121212", "text_color": "#ffffff", "border_radius": 4, "font_family": "inherit" }, "form": { "copy": { "header": "Get an alert", "terms": "One email when it is back. No spam." }, "style": { "background_color": "#ffffff", "text_color": "#202223", "button_background_color": "#121212", "button_text_color": "#ffffff" }, "inline": { "enabled": true } }, "products": [ { "collection": "gid://shopify/Collection/123", "button_visibility": "always_show" }, { "targets": [{ "shopify_product_id": "gid://shopify/Product/45" }], "restock_message": "Back in March" }, { "targets": [{ "shopify_product_id": "gid://shopify/Product/46" }], "template": "minimal" } ], "css": ".restock-rocket-button { text-transform: uppercase; }"}Only the fields you send change. The shop-wide fields are the widget section’s (PATCH /back_in_stock/settings/widget): button, form.copy, form.messages, form.style, form.fields, form.inline.enabled and optin.success_text, checked by that section’s rules. Where the widget shows (placement, selectors), the channels, double opt-in and alerts are not design fields. Send locale to write the texts in another language.
products is a list of up to 10 groups. Each names targets (product gids for every variant, variant gids for one) or a collection (up to 100 products), and the values those rows get, as in PATCH /back_in_stock/products:
button_visibility:always_showkeeps notify-me visible even while in stock and turns automatic back-in-stock alerts off for those variants, so the merchant notifies those signups by hand;when_out_of_stock(the default);never_showhides the button.restock_message: plain text under the button.template(a library template with a per-product widget; apply creates it as one of the shop’s widget templates, markedstoq-design:<id>, and reuses it next time) orwidget_template_id(one the shop has).automatic_alerts_disabled: sets the alerts directly, and wins overalways_show.
A product may be in one group only. If per-product customization is off for the shop, apply turns it on, and preview says how many other rows already have stored values that start to apply. Preview and apply return alerts, one line per change to automatic alerts or button visibility; the tool tells the agent to pass every line on.
What is cleaned or refused
Section titled “What is cleaned or refused”-
HTML fields (
form.copy.description,form.copy.terms,form.copy.promotion_consent_label,form.messages.success) keep formatting tags only, as fordesign_preorder. Consent and terms wording also losesclassandstyle, so it keeps the form’s colours. Plain-text fields (the button text, the form header, labels, placeholders, error messages, the restock note) lose all markup. -
CSS (and inline
stylein the HTML fields) is refused, not rewritten, under the same rules asdesign_preorder, for STOQ’s notify-me elements (.restock-rocket-button,.restock-rocket-restock-note, the form’s#form-*and#formContainerids), with a stricter list per element:- the notify-me and submit buttons: border, corners, font weight, style and case only;
- the button’s container, the form frame, inputs, consent checkbox, consent text and terms: spacing, corners, alignment, font weight, style and case only;
- the other elements (header, description, success text, restock note): no sizes, shadows, outlines, generated text or bidi overrides.
Colours come only from the colour fields (
button.*_color,form.style.*), which are contrast-checked. Fonts areinherit(the theme’s own), generic families or common text faces, because ornament and icon fonts draw symbols in place of letters. -
Colours the design changes must contrast with their background: 3:1 for the buttons and the restock note, 4.5:1 for the form text (consent and terms use it).
The design CSS sits in its own block of the shop’s custom CSS (/* stoq-design:back_in_stock start */ … end), so the merchant’s own rules and preorder designs are never touched.
Thanks for letting us know.
Still stuck? Ask Quinn or chat with support