Skip to main content
POST
/
api
/
v1
/
discounts.json
Create Discount
curl --request POST \
  --url https://api.launchmystore.io/api/v1/discounts.json \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "code": "<string>",
  "title": "<string>",
  "type": "<string>",
  "value": 123,
  "usage_limit": 123,
  "once_per_customer": true,
  "minimum_order_amount": 123,
  "minimum_quantity": 123,
  "applies_to": "<string>",
  "product_ids": [
    {}
  ],
  "collection_ids": [
    {}
  ],
  "customer_eligibility": "<string>",
  "customer_ids": [
    {}
  ],
  "starts_at": "<string>",
  "ends_at": "<string>",
  "combines_with_product_discounts": true,
  "combines_with_shipping_discounts": true
}
'
{
  "success": true,
  "data": {}
}

Documentation Index

Fetch the complete documentation index at: https://docs.launchmystore.io/llms.txt

Use this file to discover all available pages before exploring further.

Create Discount

Creates a new discount code in the store.

Request

curl -X POST "https://api.launchmystore.io/api/v1/discounts.json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "SUMMER20",
    "title": "Summer Sale 20% Off",
    "type": "percentage",
    "value": 20,
    "usage_limit": 500,
    "once_per_customer": true,
    "minimum_order_amount": 5000,
    "starts_at": "2024-06-01T00:00:00Z",
    "ends_at": "2024-08-31T23:59:59Z"
  }'

Body Parameters

code
string
required
Unique discount code (case-insensitive, alphanumeric and dashes only)
title
string
Internal title/description for the discount
type
string
required
Discount type: percentage, fixed_amount, free_shipping, buy_x_get_y
value
number
required
Discount value. For percentage, enter 20 for 20%. For fixed_amount, enter amount in cents (2000 for $20.00).
usage_limit
integer
Maximum number of times the discount can be used (null for unlimited)
once_per_customer
boolean
default:"false"
Limit to one use per customer
minimum_order_amount
integer
Minimum order amount in cents (null for no minimum)
minimum_quantity
integer
Minimum quantity of items required (null for no minimum)
applies_to
string
default:"all"
What the discount applies to: all, specific_products, specific_collections
product_ids
array
Array of product IDs (required when applies_to is specific_products)
collection_ids
array
Array of collection IDs (required when applies_to is specific_collections)
customer_eligibility
string
default:"all"
Who can use: all, specific_customers, specific_segments
customer_ids
array
Array of customer IDs (required when customer_eligibility is specific_customers)
starts_at
string
Start date (ISO 8601). Defaults to now if not provided.
ends_at
string
End date (ISO 8601). Null for no expiration.
combines_with_product_discounts
boolean
default:"false"
Whether this discount can be combined with product-level discounts
combines_with_shipping_discounts
boolean
default:"false"
Whether this discount can be combined with shipping discounts

Response

success
boolean
Whether the request succeeded
data
object
The created discount object

Example Response

{
  "success": true,
  "data": {
    "id": "disc_new789",
    "code": "SUMMER20",
    "title": "Summer Sale 20% Off",
    "type": "percentage",
    "value": 20,
    "value_type": "percentage",
    "status": "scheduled",
    "usage_count": 0,
    "usage_limit": 500,
    "once_per_customer": true,
    "minimum_order_amount": 5000,
    "minimum_quantity": null,
    "applies_to": "all",
    "product_ids": [],
    "collection_ids": [],
    "customer_eligibility": "all",
    "starts_at": "2024-06-01T00:00:00Z",
    "ends_at": "2024-08-31T23:59:59Z",
    "created_at": "2024-05-15T10:00:00Z",
    "updated_at": "2024-05-15T10:00:00Z"
  }
}

Buy X Get Y Example

Create a “Buy 2 Get 1 Free” discount:
{
  "code": "B2G1FREE",
  "title": "Buy 2 Get 1 Free",
  "type": "buy_x_get_y",
  "buy_x_get_y": {
    "buy_quantity": 2,
    "get_quantity": 1,
    "get_discount_type": "percentage",
    "get_discount_value": 100,
    "applies_to": "same_product"
  },
  "starts_at": "2024-06-01T00:00:00Z"
}

Error Codes

CodeDescription
UNAUTHORIZEDInvalid or missing access token
FORBIDDENApp doesn’t have write_discounts scope
VALIDATION_ERRORInvalid request body (see error details)
DUPLICATE_CODEA discount with this code already exists