# API: List promotion codes

# listPromoCodes

A list of available promotion codes

TIP

This API call uses pagination for results.

# Optional parameters

Parameter Description
page Which page to return (default:0)
include_batch When set to 1 results will also include coupons related to batches, which are not listed by default

# Request

GET /admin/api.php?api_id=API_ID&api_key=API_KEY&call=listPromoCodes

# PHP Samples

$url = 'http://url_to_hb.com/admin/api.php';
$post = [
  'call' => 'listPromoCodes',
  'api_id' => $API_ID,
  'api_key' => $API_KEY,

];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($ch);
curl_close($ch);

$return = json_decode($data, true);
print_r($return);
include 'class.hbwrapper.php';
HBWrapper::setAPI('http://url_to_hb.com/admin/api.php','API ID','API Key');
$params = [

];
$return = HBWrapper::singleton()->listPromoCodes($params);
print_r($return);
/* Use this method to access HostBill api from HostBill modules */
$api = new ApiWrapper();
$params = [

];
$return = $api->listPromoCodes($params);
print_r($return);

# Response

{
    "success": true,
    "coupons": [
        {
            "id": "9",
            "code": "MN634HMI7L6B",
            "status": "Active",
            "coupon_type": "cart",
            "type": "percent",
            "value": "11.000",
            "num_usage": "0",
            "notes": ""
        },
        {
            "id": "3",
            "code": "6TO0CDNM1",
            "status": "Active",
            "coupon_type": "cart",
            "type": "percent",
            "value": "3.000",
            "num_usage": "0",
            "notes": ""
        },
        {
            "id": "1",
            "code": "MN634HMI7L6B",
            "status": "Active",
            "coupon_type": "cart",
            "type": "percent",
            "value": "11.000",
            "num_usage": "0",
            "notes": ""
        }
    ],
    "call": "listPromoCodes",
    "sorter": {
        "perpage": 25,
        "totalpages": 1,
        "sorterrecords": "3",
        "sorterpage": 1
    },
    "server_time": 1611584941
}
Last Updated: 9/30/2024, 2:47:06 PM