Skip to Content
Appwright
Features

Workers

Create, publish, and manage workers

Workers are the unit of code in Bound. Each worker is a JavaScript fetch handler you write in the app’s code editor, deployed to your store’s own isolated environment on Cloudflare.

Creating a worker

From the Workers page, click Create worker. The creation page has four fields:

FieldDescription
TitleThe merchant-facing label shown in the dashboard.
SourceThe worker code, prepopulated with a working default handler so a new worker does something sensible immediately.
HandleThe URL-safe identifier, auto-filled from the title as you type (until you edit it yourself). Lowercase letters, numbers, and dashes, 1–63 characters, starting and ending with a letter or number. The handle determines the worker’s storefront URL and its name in Shopify Flow, and it’s shown with the worker’s URL prefix (/apps/bound/) so you can see exactly what you’re claiming.
Shopify API versionsThe pinned Admin and Storefront API versions this worker’s queries run against. Defaults to the newest stable release; the dropdowns offer the five most recent stable versions.

Workers are live as soon as they’re created — creating deploys the worker and makes it reachable at its URL and from Flow.

The Workers list

The Workers page lists all of your workers with their status (Active or Draft badge) and creation date. You can search by title, sort by newest first, name, or status, and page through the list. If your plan’s worker limit is reached, a banner tells you and the create action is disabled until you delete a worker or upgrade. Drafts count toward the limit — they reserve their handles.

The worker page

A worker’s own page is where you do everything else. Its interface elements:

ElementDescription
Save barEdits to any field are local drafts until you hit Save (or Discard). Navigating away with unsaved changes asks for confirmation.
TitleRename the display label freely; it affects nothing externally.
SourceThe code editor. It autocompletes and documents the this.ctx.props API and the Workers Response API as you type, lints your secret usage live (unknown, not-enabled, and enabled-but-unused secrets are all flagged), and re-checks itself as you toggle secrets.
Shopify API versionsChange this worker’s Admin/Storefront pins. This is a plain settings change: no redeploy, and no new version-history entry.
Worker URLThe worker’s live storefront URL with a copy button, and an Edit action to rename the handle. Renaming redeploys under the new handle and deletes the old one, and the page warns you first: flows and storefront links using the old handle will stop working.
Worker Status (aside)Publish and unpublish. Unpublish takes the worker offline (its URL and Flow action fail) while keeping its code and full version history. Publish redeploys the last saved code — it’s disabled while you have unsaved edits, because it deploys the saved code, not your draft.
Secrets (aside)Enable individual secrets for this worker. See Secrets.
Version (aside)The worker’s version history. See below.
DeletePermanently deletes the worker, its code, and its version history. This can’t be undone.

Version control

Every save that changes the source records a new version, stamped with its save date and the staff member who saved it. Changes to metadata only (title, handle, secrets, API versions) don’t create versions.

From the Version section you can:

  • See the current version and recent past versions, or open View all for the full history.
  • Click any past version to preview it in place — the editor shows that version’s source read-only, all other fields pin to the saved worker, and the save bar is hidden.
  • Restore a previewed version. Restoring doesn’t roll back history — it saves the old source as a brand-new current version (and redeploys it if the worker is active), so the restore itself is recorded and can itself be undone by restoring again.

How many past versions are kept depends on your plan; when the cap is reached, the oldest versions (and their stored code) are pruned automatically. The live version is never pruned.

Accessing a deployed worker

Published workers are reachable on your store’s domain through the app proxy:

https://<your-shop>/apps/bound/<handle>

The exact URL is shown on the worker’s page with a copy button. The endpoint accepts any HTTP method and passes the request through to your fetch handler unchanged — method, headers, body, and query string all arrive as sent.

Drafts have nothing deployed, so their URL (and Flow action) fails until published. There is no storefront preview for drafts — the in-admin version preview is read-only and unrelated to the live URL.

Workers also run from Shopify Flow via the “Run worker” action — see Flow.

The worker API

Inside your worker, platform capabilities are available on this.ctx.props:

// You write the body of the worker's fetch handler — `request` is the
// incoming request, and `this.ctx.props` carries your capabilities.
const { data } = await this.ctx.props.admin.query(`#graphql
  query { shop { name } }
`);

return Response.json(data);
PropertyDescription
this.ctx.props.adminAdmin GraphQL API client, authenticated for you.
this.ctx.props.storefrontStorefront GraphQL API client, authenticated for you.
this.ctx.props.secretsValues of the secrets you’ve explicitly enabled for this worker.

The full, fully typed API surface — including error semantics and the execution context — is documented in References.

Best practices

  • Return a Response. Your code is the body of a fetch handler; whatever you return is what the caller receives.
  • Enable only the secrets a worker needs. The allowlist is per worker for a reason — a worker that never calls a third-party API shouldn’t hold its key.
  • Check GraphQL errors yourself. A Shopify GraphQL response with an errors array still comes back as a normal result — only non-2xx HTTP responses throw. Check data and any userErrors fields before assuming success.
  • Catch ShopifyApiError where it matters. A failed Shopify API call throws an error with a status property. If a failure should produce a specific response (or a retryable 5xx for Flow), handle it explicitly.
  • Keep Flow-triggered responses small. Response bodies to Flow are truncated at 45 KB. Return identifiers and summaries, not bulk data.
  • Use this.ctx.waitUntil() for side work. Logging to an external service or any fire-and-forget call can run after the response is sent, keeping your endpoint fast.
  • Treat handles as permanent. Renaming a handle changes its URL and breaks Flow steps that reference the old name. Pick stable handles early.

Common pitfalls

  • this.env is empty. User workers run with no bindings of their own — capabilities arrive exclusively through this.ctx.props. Code written for a generic Cloudflare Worker that reads env.SOMETHING won’t work here; create a secret and enable it on the worker instead.
  • Drafts aren’t reachable. Unpublished workers keep their code and history but their URL and Flow action fail. If a storefront endpoint 404s or a Flow run reports the worker as unpublished, check the status banner.
  • Secrets must be enabled per worker. Creating a secret doesn’t give any worker access to it — enable it on the worker’s page and save. The editor flags references to secrets that aren’t enabled.
  • Unhandled exceptions become opaque 500s. A throw escapes to the caller as a bare 500 Internal Server Error with no detail. Use try/catch and return informative responses for expected failure modes — while debugging, catch the error and return its message in the response yourself.
  • CPU time is capped at 30 seconds per invocation. Long-running work needs to be broken up or moved elsewhere.
  • Every run counts toward your monthly run limit — including failed runs and runs rejected for being over the limit. If you’re near the cap, note that Flow retries a failing action for up to 36 hours, and each retry counts.
  • Renaming breaks references. Flow workflow steps and storefront links using the old handle stop working immediately after a rename.