Webhook Integration

Premium users can trigger a request to your own endpoint when entries are created. We currently offer two Webhook types which you can setup.

These will currently only trigger for Subscribe actions and will work just like any normal integration.

Webhooks have the advantage of including custom fields and other data that we don't currently sync with mail providers. Which makes them excellent for building your own integrations or sending data to an unsupported email provider.

Note

Integration Webhooks are not instant (except for Captures), they pass through our Fraud filter first before being sent to your endpoint. The process usually takes 5-10 minutes.

Our webhooks will create a POST request containing a JSON body to your endpoint. Example JSON:

{
   "campaign":{
      "name":"My Campaign",
      "key":"a1XyD",
      "type":"Competition"
   },
   "reward":{
      "type":"Download",
      "code":"1234"
   },
   "coupon":{
      "type":"Coupon",
      "code":"1234"
   },
   "user":{
      "name":"Joe Bloggs",
      "first_name":"Joe",
      "last_name":"Bloggs",
      "email":"joe@example.com",
      "country":"Australia",
      "region":"Queensland",
      "city":"Bloggstown",
      "country_code":"AU",
      "actions_completed":1,
      "details":{
         "I have read the terms and conditions":"true",
         "How are you?":"Great, thanks!",
         "Postcode":8282
      }
   },
   "entry":{
      "id":244523423,
      "entry_method_id":334222,
      "action":"Subscribe to our newsletter",
      "created_at":"2015-11-18 05:14:37 UTC",
      "type":"email_subscribe",
      "value":"Example user answer",
      "worth":1,
      "landing_url":"https://example.com", 
      "referring_url":"https://example.com",
      "upload":{
         "original_url":"https://example.com/image.jpg",
         "thumb_url":"https://example.com/image2.jpg",
         "post_url":"https://instagram.com/some_post/",
         "post_text":"Hello world",
         "content_type":"image/jpeg"
      }
   },
   "social_links":[
      {
         "provider":"twitter",
         "uid":"1345519622",
         "reference":"gleamapp"
      }
   ]
}

These Webhooks are setup on the Post Entry tab of Competitions and Rewards. They will send through a Webhook POST every time an action is completed.

This request will also show things like the total number of entries for that user (for Competitions) and their progress towards unlocking a Reward.

Our webhooks will create a POST request containing a JSON body to your endpoint. Example JSON:

{
   "campaign":{
      "name":"My Campaign",
      "key":"a1XyD",
      "type":"Competition"
   },
   "reward":{
      "type":"Download",
      "code":"1234"
   },
   "coupon":{
      "type":"Coupon",
      "code":"1234"
   },
   "user":{
      "name":"Joe Bloggs",
      "first_name":"Joe",
      "last_name":"Bloggs",
      "email":"joe@example.com",
      "country":"Australia",
      "region":"Queensland",
      "city":"Bloggstown",
      "country_code":"AU",
      "actions_completed":1,
      "details":{
         "I have read the terms and conditions":"true",
         "How are you?":"Great, thanks!",
         "Postcode":8282
      }
   },
   "entry":{
      "id":244523423,
      "entry_method_id":334222,
      "action":"Subscribe to our newsletter",
      "created_at":"2015-11-18 05:14:37 UTC",
      "type":"email_subscribe",
      "value":"Example user answer",
      "worth":1,
      "landing_url":"https://example.com",
      "referring_url":"https://example.com",
      "upload":{
         "original_url":"https://example.com/image.jpg",
         "thumb_url":"https://example.com/image2.jpg",
         "post_url":"https://instagram.com/some_post/",
         "post_text":"Hello world",
         "content_type":"image/jpeg"
      }
   },
   "social_links":[
      {
         "provider":"twitter",
         "uid":"1345519622",
         "reference":"gleamapp"
      }
   ]
}

If you need to whitelist IP addresses, the requests from Gleam's webhooks will come from 173.255.204.234 or 45.79.6.209

You will need to have an endpoint that can receive the POST request from Gleam.

The user, campaign, and entry details will be mapped to Rails parameters.

For a generic Ruby solution, you can use:

require 'json'

data_json = JSON.parse request.body.read
<?php
$data = json_decode(file_get_contents('php://input'), TRUE);
print_r($data,true);
?>

See Next Article

Widget Callback

Business and Premium users can set up widget callback for the Gleam widget to send events which you can listen for on your website.