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.

Webhooks

Get notifications for events in your account.


Use webhooks to be notified about events that happen in a Coupontools account.

Webhooks are a system of automated notifications indicating that an event has occurred in your account. Rather than requiring you to pull information via our API, webhooks push information to your destination when important events occur.

Notifications are delivered via HTTP POST to a destination endpoint on your server and are sent based on the triggers you choose. Each webhook contains a notification kind and the full Coupontools object that the notification is reporting on. This information can be used to update your system or to trigger business processes.

Configuration
To configure a webhook, you'll need to::
  • 1. Create a webhook destination URL on your server
  • 2. Create a new webhook in the Control Panel by entering your webhook destination URL and selecting at least one type of notification for the webhook to fire on
  • 3. Set up your server to parse incoming webhooks
  • 4. Test your webhook handling code
Retries
We will resend webhook notifications every hour for up to 24 hours until both of the following are true::
  • - The webhook responds within 30 seconds.
  • - The webhook responds with a successfull HTTP response code.(i.e. 2xx)
Example
Example PHP script to process the webhook callback.
<?php
	$input = @file_get_contents("php://input");
	$event_json = json_decode($input);

	$from = "Yourcompany.com";

	$headers = "From: $from\n";
	$headers .= "Content-type: text/html; charset=utf-8\n";
	$headers .= "MIME-Version: 1.0\n";

	$gmdate = gmdate("Y-m-d H:i:s");
	$message = "Date = ". $gmdate . "<br>";
	$message .= "<br /><hr><br /><pre>";
	$message .= print_r( $event_json, true );
	$message .= "</pre><br /><hr><br />";

	### SEND LOGGING MAIL ###
	$to = "info@youremailcomeshere.com";
	$subject = "Webhook received";
	mail("$to","$subject","$message",$headers);

	### WEBHOOK PROCESSED ###
	echo "OK";
?>
Example webhook for coupon
Possible actions:
{
	"id": "evt_6paDkhIBCpWrUK8ne7rT",
	"datetime": "2021-10-21 03:04:28",
	"livemode": "0",
	"type": "coupon_claimed",
	"coupon_code": "2e8g45wmyawppwubnk5r7",
	"session": "2e8g45wmyawppwubnk5r7",
	"campaign": "cam_12345",
	"coupon_url": "https://www.digicpn.com/p/u3s3dg/2e8g45wmyawppwubnk5r7",
	"coupon": {
		"coupon_code": "u3s3dg",
		"friendly_name": "Here comes your campaign name",
		"title": "The coupon title comes here",
		"subtitle": "The coupon subtitle comes here",
		"tags": "Here comes the coupon tags",
		"coupon_value": "",
		"custom_validation_code": "",
		"customid": "",
		"timezone": "UTC"
	},

	"status": {
		"social_login": "0",
		"scratched": "0",
		"scratched_date": "",
		"claimed": "1",
		"claimed_date": "2021-10-21 03:04:28",
		"claimed_type": "db",
		"validated": "0",
		"validated_date": ""
	},

	"customer": {
		"gender": "Male",
		"first_name": "First Name",
		"last_name": "Last Name",
		"email": "info@email.com",
		"phone": "11234567890",
		"address": "Address",
		"zip": "10000",
		"city": "City",
		"birthday": "1980-01-01",
		"custom_field_1": "Custom field 1",
		"custom_field_2": "Custom field 2",
		"custom_field_3": "Custom field 3",
		"custom_field_4": "Custom field 4",
		"custom_field_5": "Custom field 5",
		"custom_field_6": "Custom field 6",
		"custom_field_7": "Custom field 7",
		"question_1": "Answer 1"
	}
}
Example webhook for editing coupons
Possible actions:
		{
			"id":"evt_rmGqtgKU7zvLppIYUKN5",
			"datetime":"2021-10-21 03:04:28",
			"type": "coupon_created",
			"coupon": "cam_1026090",
			"subaccount": "sub_3427"
		}
		
Example webhook for landing page
Possible actions:
				{
					"id": "evt_okhTzyxLUxldgcpgec6X",
					"datetime": "2021-05-06 13:24:48",
					"type": "lp_submission",
					"landing_id": "lp_12345",
					"target_coupon": "cam_1234567",
					"target_statcode": "2e8g45wmyawppwubnk5r7",
					"target_url": "https://www.digicpn.com/p/u3s3dg/2e8g45wmyawppwubnk5r7",
					"data": {
						"E-mail": "info@email.com",
						"phone": "11234567890"
					}
				}
		
Example webhook for editing subaccounts
Possible actions:
		{
			"id":"evt_rmGqtgKU7zvLppIYUKN5",
			"datetime":"2021-10-21 03:04:28",
			"type": "subaccount_created",
			"subaccount": "sub_3427"
		}
		

Regístrate ahora para una cuenta de prueba por 7 días

¡Empieza a usar Coupontools hoy!

¡Genial, estás aquí! ¿Cookies? Lee nuestrasPolíticas de Privacidad. Yo acepto
x