I need to use the admin API to query a plugin. Do you need Shopify Plus or is there another way?

I need to query a GraphQL function such as Steppun discount to generate a custom coupon code.

In my Shopify admin, I have the GraphQL app and I use:

{
  shopifyFunctions(first: 100) {
    nodes {
      id
      title
      app {
        id
        title
      }
    }
  }
}

to check out which function to use. I then create another query to generate the discount code:

mutation discountCodeAppCreate($codeAppDiscount: DiscountCodeAppInput!) {
  discountCodeAppCreate(codeAppDiscount: $codeAppDiscount) {
    codeAppDiscount {
      discountId
      title
      appDiscountType {
        description
        functionId
      }
      codes(first:50) {
        nodes {
          code
        }
      }
      status
    }
    userErrors {
      field
      message
    }
  }
}

with the following graphql variabls:

{
  "codeAppDiscount": {
    "code": "MY100FREE",
    "title": "100% off",
    "functionId": "333dab63-45b5-4b16-987e-bcc0f57ac562",
    "startsAt": "2025-11-07T00:00:00Z",
    "endsAt": "2025-12-31T23:59:59Z",
    "appliesOncePerCustomer": true,
    "combinesWith": {
      "orderDiscounts": false,
      "productDiscounts": false,
      "shippingDiscounts": false
    },
    "metafields": [
      {
        "namespace": "steppun_discount",
        "key": "quantity_limit_config",
        "type": "json",
        "value": "{ \"maxQuantity\": 1, \"effect\": { \"percentage\": 1.0 } }"
      },
      {
        "namespace": "steppun_discount",
        "key": "overflow_charge_config",
        "type": "json",
        "value": "{ \"overflowQuantityBehaviour\": \"charge_difference\" }"
      }
    ]
  }
}

but on the Admin API I get:

{
    "data": {
        "discountCodeAppCreate": {
            "codeAppDiscount": null,
            "userErrors": [
                {
                    "field": [
                        "codeAppDiscount",
                        "functionId"
                    ],
                    "message": "Function 333dab63-45b5-4b16-987e-bcc0f57ac562 not found. Ensure that it is released in the current app (259966828545), and that the app is installed."
                }
            ]
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 20,
            "actualQueryCost": 10,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1990,
                "restoreRate": 100.0
            }
        }
    }
}

basically the app ID is the actual Shop. I’m also unable to query the functions using the Admin API as it just gets me an empty node:

{
    "data": {
        "shopifyFunctions": {
            "nodes": []
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 20,
            "actualQueryCost": 2,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1998,
                "restoreRate": 100.0
            }
        }
    }
}

I am unsure if this functionality is only available to shopify plus customers only. I’m on the regular shopify. What are the other options to create a discount code programatically using the API on the fly please?

Thanks

I believe this is failing because you need to be the owner of the discount function in order to create instances of it - such that you need to use Stepun’s API credentials to create the discount.

YOU can use discountRedeemCodeBulkCreation to generate redeem codes for an existing discount code (regardless of the app that created them). So your approach would change - you won’t try to create the Steppun discount, you would manually create through their interface, and then generate redeem codes for that discount code.

I will say that this is an async bulk API - so you have to create the job, and then read the results - so it’s not super simple.

There are apps on the app store that can do this :slight_smile:

I see thank you, what would be the best approach to create redeem codes in this case? We want to use these codes to be able to limit a purchase, for example when a user redeems points for a product, a maximum of 1 item can be added. Shopifys main issue is that it doesn’t allow for a maximum quantity but rather the full card which is annoying to be fair.