Shopify Functions APIs reference
Shopify Functions allow developers to customize the backend logic that powers parts of Shopify. This guide introduces the available APIs for Shopify Functions.
Available APIsAnchor link to section titled "Available APIs"
The following Function APIs are available:
|Delivery Customization API||Rename, reorder, and sort the delivery options available to buyers during checkout.|
|Order Discount API||Create a new type of discount that's applied to all merchandise in the cart.|
|Product Discount API||Create a new type of discount that's applied to a particular product or product variant in the cart.|
|Payment Customization API||Rename, reorder, and sort the payment methods available to buyers during checkout.|
APIs in developer previewAnchor link to section titled "APIs in developer preview"
|Cart and Checkout Validation API||Provide your own validation of a cart and checkout.|
|Fulfillment Constraints API||Provide your own logic for how Shopify should fulfill and allocate an order.|
|Order Routing Location Rule API||Provide your own ranking of location, for each item, during order routing.|
|Shipping Discount API||Create a new type of discount that's applied to one or more shipping rates at checkout.|
|Cart Transform API||Expand cart line items and update the presentation of cart line items.|
Getting startedAnchor link to section titled "Getting started"
Learn how to use Shopify Functions by following one of our use case tutorials:
Use Shopify Functions to hide a payment option offered to customers at checkout.
Use Shopify Functions to rename a delivery option offered to customers at checkout.
Cart and checkout validations
Use Shopify Functions to block progress on a checkout when the cart line quantities exceed a limit.
Order routing location rules
Use Shopify Functions to choose a different order location during checkout.
LimitationsAnchor link to section titled "Limitations"
The following limitations apply to all functions:
- Shopify doesn't allow nondeterminism in functions, which means that you can't use any randomizing or clock functionality in your functions.
- The compiled function can't exceed 256 kB in size.
- You can't debug your function by printing out
STDOUT, which is reserved for function output. Use
Function logs to
STDERRare truncated after 1 kB. Some Wasm toolchains might crash if
STDERRfails to write full logs.
The logic of the function must execute in a maximum of 11 million instructions, which can be tested locally using
At runtime, a function can't exceed the following memory limits:
- Linear memory limit: 10 MB
- Stack memory limit: 512 kB
A function's input cannot exceed 64,000 bytes in size.
Refer to input query limitations for more information.
A function's output can't exceed 20 kB in size.
An app can deploy a maximum of 50 functions.
Network access isn't supported. For example, you can't send HTTP requests to your app's backend as part of the function's logic. However, you can pre-populate data by using metafields on products and customers, or passing data using cart attributes.
- Learn about how Shopify Functions work and the benefits of using Shopify Functions.
- Learn about how data is input to and output from Shopify Functions.