<aside class="note">
<h4>Functions availability</h4>
<ul>
    <li>Users that have <a href="/docs/storefronts/themes/architecture/layouts/checkout-liquid"><code>checkout.liquid</code></a> customizations need to <a href="https://help.shopify.com/manual/checkout-settings/checkout-extensibility/checkout-upgrade">upgrade to Checkout Extensibility</a> to use Function APIs.</li>
    <li>Stores on any plan can use public apps that are distributed through the Shopify App Store and contain functions. Only stores on a <a href="https://help.shopify.com/manual/intro-to-shopify/pricing-plans/plans-features/shopify-plus-plan">Shopify Plus plan</a> can use <a href="https://help.shopify.com/manual/apps/app-types/custom-apps">custom apps</a> that contain <a href="/docs/api/functions">Shopify Function APIs</a>.</li>
    <li>Some Shopify Functions capabilities are available only to stores on a <a href="https://help.shopify.com/manual/intro-to-shopify/pricing-plans/plans-features/shopify-plus-plan">Shopify Plus plan</a>. See <a href="/docs/api/functions#availability-of-shopify-functions">Shopify Function APIs</a> for details.</li>
</ul>
</aside>


[Shopify Functions](/docs/apps/build/functions) allow developers to customize the backend logic that powers parts of Shopify. This guide introduces the available APIs for Shopify Functions.

## Availability of Shopify Functions

- **All plans**: Except as noted below, stores on any plan can use public apps that are distributed through the Shopify App Store and contain functions.

- **Shopify Plus**: Only stores on a [Shopify Plus plan](https://help.shopify.com/manual/intro-to-shopify/pricing-plans/plans-features/shopify-plus-plan) can use [custom apps](https://help.shopify.com/manual/apps/app-types/custom-apps) that contain Shopify Function APIs.

| Function API or feature | Availability |
| ----------------------- | ------------ |
| Cart Transform API [update operation](/docs/api/functions/reference/cart-transform#example-update-operation) | Only Shopify Plus stores |
| [Order Routing Location Rule API](/docs/api/functions/reference/order-routing-location-rule/) | Only custom apps on Shopify Plus stores, by request |
| [Local Pickup Delivery Option Generator API](docs/api/functions/reference/local-pickup-delivery-option-generator/) | Only custom apps on Shopify Plus stores, by request |
| [Pickup Point Delivery Option Generator API](/docs/api/functions/reference/pickup-point-delivery-option-generator) | Only custom apps on Shopify Plus stores, by request |
| [Discounts Allocator API](/docs/api/functions/reference/discounts-allocator/) | Only custom apps on Shopify Plus stores, with the [Discounts Allocator developer preview](/docs/api/developer-previews#discounts-allocator-developer-preview) |
| [Payment Customizations API](/docs/api/functions/reference/payment-customization) | Limited. [Learn more](https://help.shopify.com/en/manual/checkout-settings/checkout-customization#understanding-payment-method-customizations) |
| Network access for Shopify Functions | Limited. [Learn more](/docs/apps/build/functions/input-output/network-access#availability-of-network-access-for-functions). |

## Available APIs

The following Function APIs are available:

| Function API | Description | Extension target | Merchant interface |
| ------------ | ----------- | --- | --- |
| [Delivery Customization API](/docs/api/functions/reference/delivery-customization/) | Rename, reorder, and sort the delivery options available to buyers during checkout. | [purchase.delivery-customization.run](/docs/api/functions/reference/delivery-customization/graphql#extension-targets) | Embedded app pages |
| [Order Discount API](/docs/api/functions/reference/order-discounts/) | Create a new type of discount that's applied to all merchandise in the cart. | [purchase.order-discount.run](/docs/api/functions/reference/order-discounts/graphql#extension-targets) | Admin UI extensions, Embedded app pages |
| [Product Discount API](/docs/api/functions/reference/product-discounts/) | Create a new type of discount that's applied to a particular product or product variant in the cart. | [purchase.product-discount.run](/docs/api/functions/reference/product-discounts/graphql#extension-targets) | Admin UI extensions, Embedded app pages |
| [Shipping Discount API](/docs/api/functions/reference/shipping-discounts/) | Create a new type of discount that's applied to one or more shipping rates at checkout. | [purchase.shipping-discount.run](/docs/api/functions/reference/shipping-discounts/graphql#extension-targets) | Admin UI extensions, Embedded app pages |
| [Payment Customization API](/docs/api/functions/reference/payment-customization/) | Rename, reorder, and sort the payment methods available to buyers during checkout. | [purchase.payment-customization.run](/docs/api/functions/reference/payment-customization/graphql#extension-targets) | Embedded app pages |
| [Cart Transform API](/docs/api/functions/reference/cart-transform/) | Expand cart line items and update the presentation of cart line items. | [purchase.cart-transform.run](/docs/api/functions/reference/cart-transform/graphql#extension-targets) | None |
| [Cart and Checkout Validation API](/docs/api/functions/reference/cart-checkout-validation/) | Provide your own validation of a cart and checkout. | [purchase.validation.run](/docs/api/functions/reference/cart-checkout-validation/graphql#extension-targets) | Admin UI extensions |
| [Fulfillment Constraints API](/docs/api/functions/reference/fulfillment-constraints) | Provide your own logic for how Shopify should fulfill and allocate an order. | [purchase.fulfillment-constraint-rule.run](https://shopify.dev/docs/api/functions/reference/fulfillment-constraints/graphql#extension-targets) | None |
| [Local Pickup Delivery Option Generator API](/docs/api/functions/reference/local-pickup-delivery-option-generator/) | Generate custom local pickup options available to buyers during checkout. | [purchase.local-pickup-delivery-option-generator.run](/docs/api/functions/reference/local-pickup-delivery-option-generator/graphql#extension-targets) | None |
| [Pickup Point Delivery Option Generator API](/docs/api/functions/reference/pickup-point-delivery-option-generator/) | Generate custom pickup point options available to buyers during checkout. | [purchase.pickup-point-delivery-option-generator.run](/docs/api/functions/reference/pickup-point-delivery-option-generator/graphql#extension-targets) | None |

## APIs in developer preview

<aside class="note beta">
<h4>Developer preview</h4>
<p>The following Function APIs are available only in the <a href="/docs/api/developer-previews#checkout-and-customer-accounts-extensibility-developer-preview">Checkout and Customer Accounts Extensibility developer preview</a>.</p>
</aside>

| Function API | Description | Extension target | Merchant Interface |
| ------------ | ----------- | --- | --- |
| [Order Routing Location Rule API](/docs/api/functions/reference/order-routing-location-rule/) | Provide your own ranking of location, for each item, during order routing. | [purchase.order-routing-location-rule.run](/docs/api/functions/reference/order-routing-location-rule/graphql#extension-targets) |  Admin UI extensions |
| [Discounts Allocator API](/docs/api/functions/reference/discounts-allocator/) | Provide your own logic for how discounts should be calculated and allocated to a given cart. | [purchase.discounts-allocator.run](/docs/api/functions/reference/discounts-allocator/graphql#extension-targets) | None |

## Getting started

Learn how to use Shopify Functions by following one of our use case tutorials:

<div class="resource-card-grid">
  <div>
  <a class="resource-card" href="/docs/apps/build/discounts/build-discount-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/heart"
     data-alt-src="/assets/resource-cards/heart-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Build a discount function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to create a new discount type for users.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/checkout/payments/create-payments-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/coin"
     data-alt-src="/assets/resource-cards/coin-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Create a payments function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to hide a payment option offered to customers at checkout.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/checkout/delivery-shipping/delivery-options/build-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/globe"
     data-alt-src="/assets/resource-cards/globe-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Build a delivery options function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to rename a delivery option offered to customers at checkout.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/checkout/cart-checkout-validation/create-server-side-validation-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/storefront"
     data-alt-src="/assets/resource-cards/storefront-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Create a server-side validation function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to block progress on a checkout when the cart line quantities exceed a limit.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/orders-fulfillment/order-routing-apps/location-rules/build-location-rule-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/growth"
     data-alt-src="/assets/resource-cards/growth-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Build a location rule function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to choose a different order location during checkout.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/product-merchandising/bundles/add-customized-bundle-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/hearts"
     data-alt-src="/assets/resource-cards/hearts-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Add a customized bundle function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to group products together and sell them as a single unit.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/orders-fulfillment/order-routing-apps/build-fulfillment-constraints-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/tutorial"
     data-alt-src="/assets/resource-cards/tutorial-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Build a fulfillment constraints function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to customize fulfillment and delivery strategies.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/orders-fulfillment/order-routing-apps/build-local-pickup-options-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/build"
     data-alt-src="/assets/resource-cards/build-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Build a local pickup options function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to generate local pickup delivery options at checkout.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/checkout/delivery-shipping/delivery-methods/create-local-pickup-charges-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/gear"
     data-alt-src="/assets/resource-cards/gear-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Create a local pickup charges function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to create local pickup charges at checkout.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/checkout/delivery-shipping/delivery-methods/generate-pickup-points" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/gear"
     data-alt-src="/assets/resource-cards/gear-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Generate a pickup points function
    </h3>
    <p class="resource-card__description">Use Shopify Functions to generate pickup point delivery options at checkout.</p>
  </a>
</div>
</div>



## Developer tools and resources

Explore the developer tools and resources available for Shopify Functions.

<div class="resource-card-grid">
  <div>
  <a class="resource-card" href="/docs/api/functions" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/graphql"
     data-alt-src="/assets/resource-cards/graphql-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Shopify Function APIs reference
    </h3>
    <p class="resource-card__description">Learn about the available APIs for Shopify Functions.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/apps/build/functions/programming-languages" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/rust"
     data-alt-src="/assets/resource-cards/rust-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Language support
    </h3>
    <p class="resource-card__description">Learn about the language support and tooling that are available in Shopify Functions.</p>
  </a>
</div>
</div>


## API versions

Function APIs are [versioned](/docs/api/usage/versioning). Updates are released quarterly, and you can find details about changes in the [developer changelog](https://shopify.dev/changelog).


[Learn how to update to a new version of a Function API](/docs/apps/build/functions/input-output#api-versions).

## Limitations and considerations

The following limitations and considerations apply to all functions:

- Apps can reference only their own functions in GraphQL Admin API mutations, such as [`discountAutomaticAppCreate`](/docs/api/admin-graphql/latest/mutations/discountAutomaticAppCreate) and [`cartTransformCreate`](/docs/api/admin-graphql/latest/mutations/cartTransformCreate). Referencing a function from another app results in a `Function not found` error.
- Shopify doesn't allow nondeterminism in functions, which means that you can't use any randomizing or clock functionality in your functions.
- You can't debug your function by printing out `STDOUT`, which is reserved for function output. Use `STDERR` instead.
- Apps that provide dynamic editing and execution of function code aren't permitted on the Shopify App Store.
- Network access is supported for some functions, refer to [network access](/docs/apps/build/functions/input-output/network-access) for more information. You can also pre-populate data by using metafields on products and customers, or passing data using cart attributes.


## Resource limits

> Note:
> Function resource limits treat 1 kilobyte (kB) as 1000 bytes.

### Fixed limits

The following resource limits apply to all functions:

| Resource | Limit |
|-|-|
| Compiled binary size | 256 kB |
| Runtime linear memory | 10,000 kB |
| Runtime stack memory | 512 kB |
| Logs written to `STDERR` | 1 kB (truncated) |

### Dynamic limits

Certain limits are dynamic and scale based on the number of line items in a cart. The following resource limits apply to all functions for carts with up to 200 line items:

| Resource | Limit (up to 200 line items) |
|-|-|
| Execution [instruction count](https://webassembly.github.io/spec/core/syntax/instructions.html) | 11 million instructions |
| Function input | 128 kB |
| Function output | 20 kB |

For carts with more than 200 line items, these values will scale proportionally as the number of cart lines increases. Calculated limits for a function execution are available in your Partner Dashboard and can be [tested with Shopify CLI](/docs/apps/build/functions/test-debug-functions#execute-the-function-locally-using-shopify-cli).


## Next steps

- Learn about [how Shopify Functions work](/docs/apps/build/functions) and the benefits of using Shopify Functions.
- Learn about how data is [input to and output from Shopify Functions](/docs/apps/build/functions/input-output).