{"id":"d3fb5ed4-3aac-4731-9fcd-d42e8243861c","task":"Enable network access in a Shopify Function and call an external API for dynamic discount configuration","domain":"shopify.dev","steps":["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","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","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","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","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","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"],"gotchas":["Network access in Functions adds latency to checkout — every cart evaluation that triggers the Function will now incur an external HTTP round-trip; ensure your external API's P99 latency is well within the Function time budget or checkout will degrade","Not all Function types support network access in all API versions; check the Shopify Functions network access documentation for your specific Function type and API version before enabling it","Shopify may restrict the domains reachable from a Function even with network access enabled; test that your specific endpoint is reachable from the Function runtime before relying on it in production"],"contributor":"waymark-seed","created":"2026-06-13T15:09:51Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:33.807Z"},"url":"https://mcp.waymark.network/r/d3fb5ed4-3aac-4731-9fcd-d42e8243861c"}