Coupontools Logo

API & Webhooks

Connect the Coupontools platform with your apps or web projects. The Coupontools REST API allows you to query meta-data about your account, campaigns, distribution, validations, and usage data.


Warning: include(../essentials/api_and_webhooks_functions.php): Failed to open stream: No such file or directory in /opt/approot/build.20241122-150319-4e19bab9/coupontools.com/includes/api-docs.php on line 5

Warning: include(): Failed opening '../essentials/api_and_webhooks_functions.php' for inclusion (include_path='.:/usr/share/php') in /opt/approot/build.20241122-150319-4e19bab9/coupontools.com/includes/api-docs.php on line 5

Create a new campaign from a template in the directory

Allows you to update the campaign status, description text, the category or featured status.
Base URL
POST: https://api4coupons.com/v3/coupon/create
Parameters
# Parameter Input Description
1 client_id API client ID Can be found in your API documentation
Required
2 client_secret API client secret Can be found in your API documentation
Required
3 template Template ID that will be used to make the new campaign.
Required
4 issuer Issuer of the coupon
Optional
5 name Name of the coupon
Optional
6 title Title of the coupon
Optional
7 subtitle Subtitle of the coupon
Optional
8 start_date Start date of the coupon, format "yyyy-mm-dd hh:mm" for fixed or 4h / halfday / 1day / 2days / 3days / 4days / 5days / 6days / 1week for flexible
Optional
9 expiry_date Expiry date the coupon, format "yyyy-mm-dd hh:mm" for fixed or endday / 1day / 2days / 3days / 4days / 5days / 6days / 1week / 2week / 6week / 1month / 2month / 90days for flexible
Optional
10 discount_value Value of the coupon
Optional
11 logo_image URL to image
Optional
12 coupon_image URL to image
Optional
13 background_color HEXA color value (f.e. #000000)
Optional
14 button_color HEXA color value (f.e. #000000)
Optional
15 amount_limitation Number of times the coupon can be used
Optional
16 code_prefix The prefix of the custom validation code if these are generated
Optional
17 code_length A number between 10 and 25 inclusive The length of the custom validation code after the prefix if these are generated
Optional
18 code_type numeric or alphanumeric The type of the custom validation code if these are generated
Optional
<?php
	$ch = curl_init();
	$url = "https://api4coupons.com/v3/coupon/create";
	$client_id = "XXX"; // Your API client ID (required)
	$client_secret = "YYY"; // Your API client secret (required)
	$data = [
		'template' => "cam_123456"
	];
	curl_setopt($ch, CURLOPT_URL, "$url");
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_VERBOSE, true);
	curl_setopt($ch, CURLOPT_HTTPHEADER, [
		"X-Client-Id: $client_id",
		"X-Client-Secret: $client_secret",
		"Content-Type: application/json",
	]);
	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
	$response = curl_exec($ch);
?>
Example response
		{
			"status": {
				"status": "OK"
			},
			"coupon_info": {
				"ID": "cam_1010254",
				"code": "eM4SY2",
				"name": "test"
			}
		}
		
Possible errors
  • 200: Missing parameter: foo
  • 300: Unknown parameter: foo
  • 301: foo should be a positive number.
  • 303: Expirydate incorrect format, must be "yyyy-mm-dd hh:mm" or must be in list
  • 303: Startdate incorrect format, must be "yyyy-mm-dd hh:mm" or must be in list
  • 501: Template not found.

  • Register now for a 7-days trial account

    Start using Coupontools today!