Skip to content

Apply a discount code to a subscription

POST
/api/subscriptions/{id}/discounts
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.

id
required
string
Media typeapplication/json
object
discount_code
required
string
>= 1 characters <= 100 characters

Example generated

{
"discount_code": "example"
}
Media typeapplication/json
object
data
object
id

Gro discount ID, used to remove it

string
shopify_discount_id

The discount on the Shopify contract

string
title
string
nullable
discount_code
string
nullable
target_type
string
Allowed values: ORDER SHIPPING_LINE LINE_ITEM
value_type
string
Allowed values: PERCENTAGE FIXED_AMOUNT
value

A percentage, or a fixed amount in the currency’s main unit (not cents)

number
currency_code
string
nullable
recurring_cycle_limit

How many orders it applies to; null for every order

integer
nullable
status
string
Allowed values: ACTIVE EXHAUSTED REMOVED
is_active
boolean
is_shipping_discount
boolean
discount_label

Ready to show, e.g. “10% off”

string
estimated_amount

What an active order discount takes off the current subtotal

number
nullable
applied_at
string format: date-time
nullable
exhausted_at
string format: date-time
nullable
removed_at
string format: date-time
nullable
created_at
string format: date-time
updated_at
string format: date-time

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

Media typeapplication/json

Subscription or discount code not found

Media typeapplication/json