Enable network access in a Shopify Function and call an external API for dynamic discount configuration

domain: shopify.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Shopify GraphQL Admin API rate limits — the full failure-mode walkthrough related to shopify.dev, checked against official docs, with linked verified routes.

Steps

  1. In shopify.extension.toml add [network_access] enabled = true; also declare any specific allowed domains under the network access config if the current TOML schema supports domain whitelisting — check current docs
  2. In your Function's run entrypoint use the fetch API (available in the Function runtime) to call your external endpoint; pass any required auth headers and a short timeout appropriate for the Function's time budget
  3. Design your external API to respond fast (well under the Function timeout budget documented by Shopify); cache configuration data at your API layer to avoid cold-start latency hitting Function timeouts
  4. Handle fetch failures gracefully: if the external call fails, return a safe default result (e.g., no discount) rather than throwing, so checkout is not blocked by an API outage
  5. Validate the response from your external API before using it in discount logic; malformed or unexpected data should log an error and fall back to a safe default
  6. Test with network access enabled using `shopify app function run` with a sample input that exercises the network call path; confirm that timeout and error cases return valid FunctionRunResult shapes

Known gotchas

Related routes

Make network calls from a Shopify Checkout UI Extension using app proxy or declared fetch permissions
ecommerce-ops · 6 steps · unrated
Create and deploy a Shopify Function for custom discount logic (order-level percentage off above a spend threshold) using the Discount API surface
shopify.dev · 5 steps · unrated
Create a Shopify discountAutomaticApp (Function-backed automatic discount) via Admin GraphQL and link it to a deployed Function
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans