Apply a discount code to a subscription
const url = 'https://api.usegro.co/api/subscriptions/example/discounts';const options = { method: 'POST', headers: { Authorization: 'Bearer <token>', 'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json' }, body: '{"discount_code":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.usegro.co/api/subscriptions/example/discounts \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "discount_code": "example" }'Adds an existing Shopify discount code to the subscription’s contract, the same as applying it in the dashboard. The code must already exist in Shopify; how much it takes off and for how many orders comes from the code. Shopify checks the code is active and the subscription qualifies.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Body
Section titled “Request Body”object
Example generated
{ "discount_code": "example"}Responses
Section titled “Responses”object
object
Gro discount ID, used to remove it
The discount on the Shopify contract
A percentage, or a fixed amount in the currency’s main unit (not cents)
How many orders it applies to; null for every order
Ready to show, e.g. “10% off”
What an active order discount takes off the current subtotal
Example
{ "data": { "target_type": "ORDER", "value_type": "PERCENTAGE", "status": "ACTIVE" }}Shopify won’t apply it (inactive, not eligible, usage limit reached, no qualifying products and so on; reason says which), or the subscription isn’t linked to Shopify
Subscription or discount code not found