Skip to main content
Last updated: 04-Jan-2022
Rate this article:

The create_coupon call is used to create a new coupon.

URL: https://www.2checkout.com/api/products/create_coupon

HTTP Method: POST

 

Input Parameters

Parameter Description
coupon_code The string value of coupon code. Optional.
date_expire Expiration date of new coupon. (YYYY-MM-DD) Required.
type Denotes if coupon applies to shipping, sale or product. Required.
percentage_off Percentage, if supplied, to discount from purchase price. Can only be used with sale or product type coupons. (value_off must be NULL, if percentage_off used)
value_off Decimal value of amount to discount. Can only be used with sale or product type coupons. (percentage_off must be NULL, if value_off used)
minimum_purchase Decimal value indicating minimum required purchase amount before discount applies. Optional.
product_id 2CO system product ID. Can accept multiple product_ids in querystring. (i.e. product_id=112345678&product_id=987564321) Required for product coupons if select_all is not specified.
select_all If set to true (1), will select all products and override any product_ids supplied. Set to 0 to remove all product assignments. Required for product coupons if product_id is not specified.

Data Returned

Parameter Description
response_code Tells the user whether or not the operation was successful.
response_message Tells the user why the operation was or was not successful.
coupon_code ID assigned to the product by 2Checkout.

Example API Call

 curl -X POST https://www.2checkout.com/api/products/create_coupon \
    -H 'Accept: application/json' -u 'username:password' \
    -d 'coupon_code=APITEST004' -d 'date_expire=2099-12-22' -d 'type=sale' \
    -d 'value_off=5.00' -d 'minimum_purchase=10.00'

Example Successful Response

 {
       "coupon_code" : "APITEST004",
       "response_code" : "OK",
       "response_message" : "Coupon successfully created"
    }

Common Error Codes

Code Description
PARAMETER_MISSING Required parameter missing:
PARAMETER_INVALID Invalid value for parameter:
Rate this article:
Logo of Verifone