I have the same problem/question and would love an answer. We’ve posted to the partner Slack and contacted Shopify support and were told to post here instead, but it looks like Shopify hasn’t replied to any of the topics started with this question yet (over the last few months).
It is possible to create discount codes which apply to subscriptions using the GraphQL API. If you’re not yet familiar with the GraphQL API guide we have a helpful Getting Started guide
I was able to create a discount code which applies to both subscription orders and regular products using the following mutation:
mutation discountCodeBasicCreate($basicCodeDiscount: DiscountCodeBasicInput!) {
discountCodeBasicCreate(basicCodeDiscount: $basicCodeDiscount) {
codeDiscountNode {
id
}
userErrors {
code
extraInfo
field
message
}
}
}
You can also check out the examples here - https://shopify.dev/api/examples/discounts You can add the “appliesOnSubscription” and “appliesOnOneTimePurchase” fields to the “customerGets” object shown in the example.
Here are the documentation pages relevant to the request:
It is documented, just a little tricky to find! The last link in the list shows DiscountCustomerGetsInput which has the fields that go in the customerGets section of discountCodeBasicCreate. appliesOnSubscription is one of the fields for DiscountCustomerGetsInput.