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.
-
Subaccount
- Retrieve a list of subaccounts
- Retrieve info of a subaccount
- Create a subaccount
- Update a subaccount
- Create password reset url for subaccount
- Single sign on for subaccounts
-
Campaign
- Retrieve a list of your campaigns
- Retrieve information from a campaign
- Retrieve all usage data from a campaign
- Retrieve all data from one coupon session
- Update data from a coupon session
- Update data from multiple coupon sessions
- Search coupon session
- Search coupon session from a campaign
- Send single push notification
- Send push notification to all
-
Loyalty Card
- Retrieve a list of your loyalty cards
- Retrieve a list of users from a loyalty card
- Update loyalty card user
- Send single push notification
- Send push notification to all
-
Directory
- Retrieve a list of your directories
- Retrieve information from a directory
- Retrieve all campaigns from a directory
- Retrieve registered users from a directory
- Update directory user payment status
- Retrieve a list of categories
- Retrieve a list of 3rd level categories
-
Single Use
- Create a single use access URL
- Create multiple single use access URLs
- Remove a single use access URL
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": "2022-05-18 16:54:03", "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": "2022-05-18 16:54:03", "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":"2022-05-18 16:54:03", "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":"2022-05-18 16:54:03", "type": "subaccount_created", "subaccount": "sub_3427" }