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
Webhook verification
Webhooks created through the API can be verified by using the endpoint below. Or platform willBase URL
POST: https://api4coupons.com/v3/webhook/verification
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 | webhook | ID from the webhook | evt_JsOKTu2rlzjZsxPaleUx |
Example
|
4 | session | Session ID from the coupon | 8yx7hpxuu69k0zga93nix |
Example
|
<?php $ch = curl_init(); $url = "https://api4coupons.com/v3/webhook/verification"; $client_id = "XXX"; // Your API client ID (required) $client_secret = "YYY"; // Your API client secret (required) $data = [ 'webhook' => "evt_JsOKTu2rlzjZsxPaleUx" ]; 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 success response
{ "status": { "status": "OK" }, "result": "valid", "webhook": "evt_JsOKTu2rlzjZsxPaleUx", "date": "2017-10-09 09:57:57", "campaign": "cam_12345", "session": "8yx7hpxuu69k0zga93nix", "type": "coupon_validated" }
Example failed response
{ "status": { "status": "failed", "errors": { "error_message": "HTTP/1.0 422 Unprocessable entity.", "error_message_description": [ "Webhook not found." ], "error_code": [ 509 ] } } }
Possible errors
- 200: Missing parameter: session
- 200: Missing parameter: webhook
- 301: Invalid character in parameter: session.
- 301: Invalid character in parameter: webhook.
- 509: Webhook not found.