How can we retrieve the function ID when creating a discount app using the Shopify API? I found the discountAutomaticAppCreate mutation documentation here: https://shopify.dev/docs/api/admin-graphql/2025-01/mutations/discountAutomaticAppCreate but I need clarification on how to obtain the function ID for this process.
Topic summary
A developer is seeking guidance on retrieving the function ID needed for the discountAutomaticAppCreate GraphQL mutation when building a discount app.
Solution provided:
- First create and deploy a discount extension within the app (discount functions cannot be created directly in the Partner app extension)
- Once deployed, the function ID becomes visible in the Shopify Partner Dashboard under the extension details
- Alternatively, the function ID can be passed via URL parameters using
extensions.ui.pathsconfiguration when merchants create discounts from the Shopify Admin - The function ID can then be retrieved during the discount creation process
Reference: The response links to Shopify’s official documentation on building product discount functions for implementation details.
You will need to create a extension on your app first, then deploy it since discount function are not able to be created on the Partner app extension.
When extension is created, you can go to the Partner and see you extension functionId here.
Alternatively, on each discount extension, you will need to define the extensions.ui.paths, the :function_id can be pass to the url request when user create discount from the “Admin”. When processing the creating discount, we can retrieve this information
Ref the docs: Build a product discount function