2Checkout Documentation

Create Coupon

The create_coupon call is used to create a new coupon.



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


$args = array(
    'coupon_code' => '123TEST',
    'date_expire' => '2020-07-31',
    'value_off' => 1.00,
    'type' => sale,
    'minimum_purchase' => 2.00

$result = Twocheckout_Coupon::create($args);
Twocheckout::API.credentials = { :username => 'APIuser1817037', :password => 'APIpass1817037' }

new_coupon = Twocheckout::Coupon.create({:date_expire => "2020-01-01", :type => "shipping", :minimum_purchase => 1.00})
args = {
    date_expire: "2099-01-01",
    type: "sale",
    value_off: "0.01",
    minimum_purchase: "0.03"
};, function (error, data) {
    if (error) {
    } else {
twocheckout.Api.credentials({'username':'APIuser1817037', 'password':'APIpass1817037'})

params = {
    'coupon_code': 'PYTEST12',
    'date_expire': '2020-12-12',
    'type': 'shipping'

result = twocheckout.Coupon.create(params)
var dictionary = new Dictionary();
dictionary.Add("coupon_code", "DOTNETSHIPPING");
dictionary.Add("date_expire", "2012-12-10");
dictionary.Add("type", "shipping");

var result = TwocheckoutCoupon.Create(dictionary);
HashMap params = new HashMap();
params.put("coupon_code", "JAVATEST1");
params.put("date_expire", "2020-12-12");
params.put("type", "shipping");
params.put("minimum_purchase", "1.00");

TwocheckoutResponse result = TwocheckoutCoupon.create(params);
    curl -X POST \
    -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: