App Bridge Actions Reference
The App Bridge SDK exposes a class for each action family plus the rawdispatch / dispatchAndWait calls underneath. Use the classes when you can
— they validate types, manage subscriptions, and handle cleanup. Drop to the
raw API when you need an action the SDK hasn’t wrapped yet.
Calling Convention
The SDK signatures are:action is the string name (e.g. 'TOAST_SHOW'), not an object. The
SDK wraps the payload into the wire format
{ type: 'APP_BRIDGE_ACTION', action, payload, id } and posts it to the
host. The host responds with { type: 'APP_BRIDGE_RESPONSE', action, id, payload, error? }.
The action on a response is not always the request’s name: it can be the
request name (TOAST_SHOW), a <ACTION>_RESPONSE name
(SESSION_TOKEN_RESPONSE, CLIPBOARD_READ_RESPONSE, PRINT_RESPONSE, …) or
the event that answered it (RESOURCE_PICKER_SELECTION, MODAL_CLOSE,
SCANNER_CAPTURE). dispatchAndWait matches responses by id, so this
never matters to it — match by id too if you listen yourself.
For requests that wait on the merchant (resource picker, modal, scanner,
print, share, intents, clipboard reads) the admin first sends
{ type: 'APP_BRIDGE_ACK', action, id }. The ACK carries no result; it tells
dispatchAndWait the host is alive, so the 10-second timeout stops and the
promise waits for the merchant however long they take. Pass
{ timeout: ms } to change the timeout for one call (0 or null waits
forever).
Action Catalogue
Cart and BuyerJourney are checkout-only. They’re documented in detail on the
Checkout App Bridge page. Everything else runs in the
admin host.
UI Actions
Toast (TOAST_SHOW)
On the wire only the label travels:
{ message, action: { label: 'Undo' } }.
When the merchant clicks it, the admin posts TOAST_ACTION with
{ toastId } — the id of your TOAST_SHOW message. The admin answers
TOAST_SHOW itself with { toastId }, so
app.dispatchAndWait('TOAST_SHOW', …) resolves right away.
Modal (MODAL_OPEN / MODAL_CLOSE)
{ title?, message?, url?, size?: 'small' | 'medium' | 'large' | 'full', primaryAction?: { label, onAction }, secondaryActions?: Array<{ label, onAction }> }. Host events (MODAL_PRIMARY_ACTION,
MODAL_SECONDARY_ACTION, MODAL_CLOSE) are matched to the modal by
modalId and routed to your callbacks. The merchant can also close the
modal with its close button, the backdrop or Escape — you get the close
event. In React, prefer
useConfirmationModal
for an awaitable confirm dialog.
modal.close() closes only that modal (it sends its modalId). Inside an
admin action extension, a bare
app.dispatch('MODAL_CLOSE') — no modalId — closes the action modal your
extension runs in.
Loading (LOADING_START / LOADING_STOP)
Fullscreen (FULLSCREEN_ENTER / EXIT / TOGGLE)
Title Bar (TITLE_BAR_UPDATE)
{ label, onAction, disabled?, loading?, destructive? }
(loading shows a spinner and disables the button; destructive renders it
in the critical style). Breadcrumbs are { label, url? | destination?, onAction? } and render as links before the title. A click runs onAction
when you set one; otherwise a /admin/... path or absolute URL navigates the
admin (see Redirect), and any other path opens that page
of your app.
Navigation
Redirect (REDIRECT)
Resource ids are the admin’s ids — the ones in
useApi().data
(productId, orderId, …) and in resource picker selections. Products and
collections can also be opened by the numeric id themes and the Admin API
use (product.id, collection.id, legacyResourceId); orders and
customers have a single id, which is the one to pass.
Navigation Menu (NAV_MENU_UPDATE)
History (HISTORY_PUSH / REPLACE / BACK / FORWARD / GO)
window.history inside the
iframe) — the browser’s back and forward buttons follow it. The admin only
acknowledges them (HISTORY_RESPONSE); it does not change the admin’s URL.
To send the merchant to another page of your app through the admin, use
Redirect.toApp.
Resource Picker (RESOURCE_PICKER_OPEN / CLOSE)
multiple: true lets the picker return more than one resource. Pass
selectionIds (ids or handles) to pre-select — in a single-select picker the
current value is highlighted. The legacy initialSelectionIds: [{ id }] shape
still works but selectionIds is the recommended shape. filter.query
pre-fills the search box and filter.variants: false leaves variants out of
product selections. On cancel the picker responds with { selection: [] } —
selection is always an array and there is no cancelled field; an
empty selection is the cancel signal (class consumers get the dedicated
cancel event). RESOURCE_PICKER_CLOSE (picker.close()) closes an open
picker and settles it the same way.
resourceType is case-insensitive and also accepted as type. A type the
admin cannot pick from is answered with a RESOURCE_PICKER_CANCEL response
carrying error — dispatchAndWait rejects with that message, and the class
fires error then cancel.
Response payload: { pickerId, selection: [...] } — selection is always an
array (length 1 for single-select; empty on cancel).
Selection items
TheResourcePicker class and the React hooks ask for objects
(selectionFormat: 'object'). id is the resource’s id — use it with the
Admin API and admin URLs; legacyResourceId is its numeric id when the
resource has both.
Requests without
selectionFormat: 'object' — raw calls, and SDK
1.0.6 and earlier — keep the original shape: each element is a handle string
(handle for product / collection / blog / article / page / menu, email for
customer, the order number for order, id for product_variant). Object
selections from the SDK convert to that same string (`${item}`), so code
that interpolated the old strings keeps working. File pickers always return
objects:
The
file picker is the full Media Library — the merchant can search,
browse, and upload new files in-place, then
pick one or more. multiple: true returns several objects. id is the stable
mediaId; url is a permanent CDN URL. Other resource types select existing
records only.Save Bar (CONTEXTUAL_SAVE_BAR)
CONTEXTUAL_SAVE_BAR action with payload
{ action: 'SHOW' | 'HIDE' | 'UPDATE', ... }; the host emits
CONTEXTUAL_SAVE_BAR_SAVE / CONTEXTUAL_SAVE_BAR_DISCARD events which
the class routes to your subscribe callbacks — use the class.
Discard asks the merchant to confirm by default
(discardAction.discardConfirmationModal: true); pass false to discard
immediately.
Leave Confirmation (LEAVE_CONFIRMATION_ENABLE / DISABLE)
message) before the merchant closes the
admin action modal your extension runs in —
close button, backdrop or Escape. Your own app.dispatch('MODAL_CLOSE')
closes it without asking. Leave confirmation is per iframe: another
extension’s state doesn’t affect yours, and it ends when your page unloads.
Session & Auth (SESSION_TOKEN_REQUEST)
app.getSessionToken() is a thin wrapper over
dispatchAndWait('SESSION_TOKEN_REQUEST') — it resolves with the token
string and does not cache. For caching + auto-refresh (reuse the token
while more than 30s from its JWT exp, refresh otherwise), use the
SessionToken action class or the useSessionToken React hook.
The admin mints a token only for the app the requesting iframe belongs to: a
request whose apiKey names a different app is rejected.
In a top-level window the admin opened for you — a
print action’s print window — there is no
admin frame to ask. There getSessionToken() (and SessionToken,
RestApi, useSessionToken) returns the id_token the admin put in the
URL, and throws when there is none. Session tokens authenticate your
backend; the LaunchMyStore REST API (/api/v1/...) takes your app’s OAuth
access token instead.
User / Config / Environment / Features
USER_FETCH, CONFIG_FETCH, ENVIRONMENT_FETCH,
FEATURES_QUERY (raw only — the Features class does not dispatch it).
Browser APIs
Clipboard (CLIPBOARD_WRITE / CLIPBOARD_READ_REQUEST)
Scanner (SCANNER_OPEN / SCANNER_CLOSE)
- Camera — where the browser can decode barcodes (the BarcodeDetector
API, e.g. Chrome on Android), the device camera scans live and the first
code found is returned with its
format. - Manual entry — always available: the merchant types the code, or
scans it with a keyboard-emulating USB barcode scanner (the usual desktop
and POS setup). Returned with
type: 'barcode',format: 'manual'.
types narrows the camera to 'qr', 'barcode' or 'all' (default).
When the merchant dismisses the scanner the capture() promise rejects
with Error('Scanner cancelled') — there is no cancelled field on a
resolved payload. If another extension’s scanner is already open,
capture() rejects with the admin’s message (SCANNER_ERROR).
scanner.close() cancels an open capture.
The raw SCAN action does the same in one round trip:
await app.dispatchAndWait('SCAN', { types: ['qr'] }) resolves with
{ data, type, format } and rejects with 'Scanner cancelled'.
allow-modals, which
print() needs). The raw app.dispatch('PRINT') instead asks the admin to
print: it prints the admin page with everything except your iframe hidden,
which captures only your iframe’s visible area — prefer the class.
Share (SHARE)
dispatch() uses the iframe’s own navigator.share when it can; otherwise
(the browser has none there, or the frame may not use it) the admin shares
on your behalf via SHARE. It rejects when the browser cannot share at
all — check Share.isAvailable() first and fall back to copying the link.
Lifecycle
'focus' | 'blur' | 'visible' | 'hidden'. Two sources feed them:
the iframe’s own focus / blur / visibilitychange, and the admin,
which pushes APP_FOCUS / APP_BLUR / APP_VISIBLE / APP_HIDDEN when the
admin tab gains or loses focus or is hidden or shown. Only real changes fire —
a tab switch reported by both sources calls your callback once. There is no
mount event — run mount logic in your own bootstrap.
When your page unloads (the iframe navigates or is removed) the SDK sends
LIFECYCLE_UNMOUNT, and the admin releases the title bar, navigation menu,
save bar, loading bar and leave confirmation your page set.
Checkout-only Surfaces
The following actions are wired into the customer-checkout host and the post-purchase host. See Checkout App Bridge for the full contract.Cart (CART_LINES_CHANGE, DISCOUNT_CODE_CHANGE, NOTE_CHANGE, ATTRIBUTE_CHANGE, GIFT_CARD_CHANGE)
Buyer Journey (BUYER_JOURNEY_INTERCEPT_REQUEST/RESPONSE)
Block the customer from advancing to payment until your condition is met.
Error Handling
{ timeout: ms } as the third argument to change that per
call. A timeout is the most common failure mode when calling an admin-only
action from a checkout host (or vice versa) — check the table at the top of
this page for which host each action is wired to. Requests that wait on the
merchant (pickers, modals, scanner, print, share, intents, clipboard reads)
are acknowledged by the admin at once, so they never time out while the
merchant is deciding.
Complete Example
I18n (I18N_UPDATE)
The host pushes the merchant’s admin locale to your iframe and re-pushes
on every change. Subscribe via the I18n action class — it caches the
last dictionary and exposes translate / formatNumber / formatDate
helpers backed by Intl.*.
{ locale: string, dictionary: Record<string,string> }.
locale is the merchant’s admin language (for example en, es, ar),
pushed when your iframe starts and again whenever the merchant switches
language. dictionary is always empty ({}): the admin doesn’t hold your
app’s strings, so translate() returns your default (or the key) with
{{vars}} filled in. Keep your own translations keyed by locale, and use
formatNumber / formatDate for locale-aware formatting.
REST API helper (RestApi)
RestApi is an authenticated fetch for your app’s own backend — the
same model as Shopify’s authenticatedFetch. Every request carries
Authorization: Bearer <session token>; your backend verifies the token with
your client secret (see Session tokens) and reads
the store from its storeId claim.
- Relative paths resolve against your app’s origin (the iframe’s URL); absolute URLs are used as-is and still get the token.
- Plain-object and array bodies are JSON-encoded and
Content-Type: application/jsonis set unless you provide one. Strings,FormData,Blob,URLSearchParamsand streams are sent untouched. get/post/put/patch/delete/fetchJsonparse the body (JSON, otherwise text) and reject on non-2xx withError('RestApi: <status> <statusText> — <body>').fetchresolves with the rawResponse.- The token is cached until ~30 s before it expires; a
401refreshes it once and retries the request. - Session tokens are not accepted by the LaunchMyStore REST API
(
/api/v1/...). Call it from your backend with the store’s OAuth access token.api.getApiBase()resolves the API base URL if you need it for links.
Intents (INTENT_LAUNCH)
Launch another app’s admin action from inside your own — for example,
chain a “Send invoice” action after editing an order.
admin.order-details.action.render— the extension registered at that slot (action extensions first).admin.order-details.action.send-invoice— the extension whose handle issend-invoiceat that slot (<app>.<handle>and<app>-<handle>handles match too).
launchAndWait resolves with { launched: true, target } as soon as the
admin has opened the extension — it does not wait for it to finish. The
launched extension reads your payload as intent.payload in its context
(useApi().data.intent.payload). A target that matches nothing rejects
the promise.
Action constants
The SDK does not export a centralisedACTIONS enum — every action name is
a plain string passed to app.dispatch / app.dispatchAndWait. The
canonical source of truth for each name is the corresponding action class
itself:
SaveBarAction,
FullscreenAction and RedirectAction (same as Redirect.Action) — the
helpers normalizeResourceType() and adminSectionPath(), and
APP_BRIDGE_FEATURES (a readonly array of PascalCase feature names:
'Toast', 'Modal', 'ResourcePicker', …, 'Scanner', 'I18n',
'RestApi', 'Intents'). Use APP_BRIDGE_FEATURES with the local
Features helper:
app.dispatch(name, ...)
directly. Action names are case-sensitive and the host silently ignores
unknown names, so a typo will surface as a 10-second timeout in
dispatchAndWait. See Error Handling for
the recovery pattern.
See Also
- App Bridge Overview — wire format, security, and SDK initialization
- App Bridge for Checkout — Cart, BuyerJourney, and other checkout-only actions in depth
- Post-Purchase Bridge — action-by-action reference for
host: 'post-purchase'iframes - Error Handling — timeouts, rejections, and per-action failure modes
- React Hooks —
useAppBridge(),useToast(),useResourcePicker(), etc. - Session Tokens — how
app.getSessionToken()works