Webhooks ‐ setup and outputs - Heyloyalty/api GitHub Wiki

Here you will find more information regarding out webhooks. Setting up webhooks is right now done directly from within heyloyalty.

Setup

When setting up a webhooks from within Heyloyalty, start by navigating to lists and choose "edit list". From here, you are able to create a webhook and define how you wish the payload be sent and on which events. Below you can see an image of the setup page. We will refer back to this image, in the guide:

image

Below you'll see (from top to bottom) the fields available and what they do

Name Description Note
URL Your webservice URL Mandatory
Contact email In case of issues or your webservice becomes unresponsive after 3 attempts this email will recieve notification
Send as raw json Default on new webhooks optional
Simplified format An extended option. Payload will be restructure. See example in setup. optional
Test payload This is an extension made for Navision optional
Authentication type If you wish to add authentication to your webservice. Basic Auth and Oauth2 is available optional

Below you're able to define what eventtypes should send webhooks to your service. Choose from (minimum one option needs to be checked):

  • New subscriber (email, phone)
  • New subscriber (heypush)
  • Update subscriber
  • Unsubscribe subscriber
  • Spam complaint
  • Click (when a subscriber clicks in an email)
  • Opening (when a subscriber opens an email)
  • Hard bounces (when a subscriber's email address hard bounces)
  • Anonymized subscriber
  • Sent (when a subscriber receives an email)
  • Send a reply back at transactional emails

Webhook output

Depending on your chosen settings webhooks come in different format. By default, they are structured as a json-object

Member subscribe

{
    "member_id": "aacd0c54-fb21-46c5-823c-a1bb1703d713",
    "list_id": 1,
    "type": "subscribe",
    "signature": "a96cb5a5d8e45af7310adbfe14aab9e0",
    "member": {
        "list_id": 1,
        "status": {
            "status": "active",
            "email": null,
            "mobile": null
        },
        "fields": {
            "firstname": "John",
            "lastname": "Doe",
            "email": "[email protected]",
            "mobile": "000000",
            "birthdate": "1973-06-26T00:00:00+0000",
            "address": "Loyalitetsvej 1",
            "postalcode": 8200,
            "country": {
                "id": 53,
                "value": "Danmark"
            },
            "sko": [
                {
                    "id": 5835,
                    "value": "43"
                }
            ],
            "bluse": [
                {
                    "id": 2,
                    "value": "L"
                },
                {
                    "id": 4,
                    "value": "s"
                }
            ],
            "sent_mail": 0,
            "sent_sms": 0,
            "open_rate": 0,
            "imported": false,
            "created_at": "2015-03-04T06:46:45+0000",
            "updated_at": "2015-03-04T06:46:45+0000",
            "created_by": null,
            "created_from": {
                "type": "internal"
            },
            "_id": "aacd0c54-fb21-46c5-823c-a1bb1703d713"
        }
    }
}

Member update including custom fields

{
    "member_id": "aacd0c54-fb21-46c5-823c-a1bb1703d713",
    "list_id": 1,
    "type": "update",
    "signature": "a96cb5a5d8e45af7310adbfe14aab9e0",
    "member": {
        "list_id": 1,
        "status": {
            "status": "active",
            "email": null,
            "mobile": null
        },
        "fields": {
            "postalcode": 8260,
            "email": "[email protected]",
            "address": "loyaltyvej",
            "birthdate": "1973-06-26T00:00:00+0000",
            "lastname": "Jensen",
            "firstname": "John",
            "mobile": "00000000",
            "country": {
                "value": "Danmark",
                "id": 53
            },
            "sko": [
                {
                    "id": 5835,
                    "value": "43"
                }
            ],
            "bluse": [
                {
                    "id": 2,
                    "value": "L"
                },
                {
                    "id": 4,
                    "value": "s"
                }
            ],
            "sent_mail": 0,
            "sent_sms": 0,
            "open_rate": 0,
            "imported": false,
            "created_at": "2015-03-04T06:46:45+0000",
            "updated_at": "2015-03-04T07:36:36+0000",
            "created_by": null,
            "created_from": {
                "type": "internal"
            },
            "_id": "aacd0c54-fb21-46c5-823c-a1bb1703d713",
            "updated_from": [
                {
                    "type": "internal",
                    "updated_at": "2015-03-04T07:36:36+0000"
                }
            ]
        }
    }
}

Member update with shopfield

{
    "member_id": "e8760a00-18de-437b-8b31-0539ccd3ea41",
    "list_id": 1,
    "type": "update",
    "signature": "4ae32890ce58e23492f1e12e348e0dd2",
    "member": {
        "list_id": 1,
        "status": {
            "status": "active",
            "email": null,
            "mobile": null
        },
        "fields": {
            "shop": [
                {
                    "value": "Min butik",
                    "id": 1
                }
            ],
            "postalcode": 8200,
            "address": "loyalitetsvej",
            "email": "[email protected]",
            "lastname": "Doe",
            "firstname": "John",
            "mobile": "00000000"
        },
        "sent_mail": 0,
        "sent_sms": 0,
        "open_rate": 0,
        "imported": true,
        "created_at": "2015-03-02T09:04:25+0000",
        "updated_at": "2015-03-04T07:55:51+0000",
        "created_by": null,
        "_id": "e8760a00-18de-437b-8b31-0539ccd3ea41",
        "created_from": {
            "type": "import"
        },
        "updated_from": [
            {
                "type": "internal",
                "updated_at": "2015-03-04T07:55:51+0000"
            }
        ]
    }
}

Member Unsubscribe

{
    "member_id": "aacd0c54-fb21-46c5-823c-a1bb1703d713",
    "list_id": 1,
    "type": "unsubscribe",
    "signature": "a96cb5a5d8e45af7310adbfe14aab9e0",
    "member": {
        "list_id": 1,
        "status": {
            "status": "removed",
            "email": null,
            "mobile": null
        },
        "fields": {
            "postalcode": 8200,
            "email": "[email protected]",
            "address": "Loyaltyvej",
            "birthdate": "1973-06-26T00:00:00+0000",
            "lastname": "Jensen",
            "firstname": "John",
            "mobile": "52335040",
            "country": {
                "value": "Danmark",
                "id": 53
            },
            "sko": [
                {
                    "id": 5835,
                    "value": "43"
                }
            ],
            "bluse": [
                {
                    "id": 2,
                    "value": "L"
                },
                {
                    "id": 4,
                    "value": "s"
                }
            ]
        },
        "sent_mail": 0,
        "sent_sms": 0,
        "open_rate": 0,
        "imported": false,
        "created_at": "2015-03-04T06:46:45+0000",
        "updated_at": "2015-03-04T07:41:40+0000",
        "created_by": null,
        "created_from": {
            "type": "internal"
        },
        "_id": "aacd0c54-fb21-46c5-823c-a1bb1703d713",
        "updated_from": [
            {
                "type": "internal",
                "updated_at": "2015-03-04T07:36:36+0000"
            }
        ],
        "deleted_from": {
            "type": "internal"
        }
    }
}

Spam complaint

{
    "member_id": "e8760a00-18de-437b-8b31-0539ccd3ea41",
    "list_id": "1",
    "ref_id": "AutoresponderID/campaignId",
    "message_type": "Autoresponder/Campaign",
    "name": "AutoresponderName/campaignName",
    "type": "spamComplaint",
    "signature": "37dafeb256992064429a6c6e6ac83617",
    "member": {
        "list_id": 1,
        "status": {
            "status": "active",
            "email": "complaint",
            "mobile": null
        },
        "fields": {
            "email": "[email protected]",
            "sent_mail": 0,
            "sent_sms": 0,
            "open_rate": 0,
            "imported": false,
            "created_at": "2016-08-30T13:18:58+0000",
            "updated_at": "2016-08-30T13:18:58+0000",
            "created_by": null,
            "updated_fields": [],
            "current_fields": [],
            "created_from": {
                "type": "internal"
            },
            "_id": "2"
        }
    }
}

Hardbounce

{
    "member_id": "e8760a00-18de-437b-8b31-0539ccd3ea41",
    "list_id": "1",
    "ref_id": "AutoresponderID/campaignId",
    "message_type": "Autoresponder/Campaign",
    "name": "AutoresponderName/campaignName",
    "type": "spamComplaint",
    "signature": "37dafeb256992064429a6c6e6ac83617",
    "member": {
        "list_id": 1,
        "status": {
            "status": "active",
            "email": "complaint",
            "mobile": null
        },
        "fields": {
            "email": "[email protected]",
            "sent_mail": 0,
            "sent_sms": 0,
            "open_rate": 0,
            "imported": false,
            "created_at": "2016-08-30T13:18:58+0000",
            "updated_at": "2016-08-30T13:18:58+0000",
            "created_by": null,
            "updated_fields": [],
            "current_fields": [],
            "created_from": {
                "type": "internal"
            },
            "_id": "2"
        }
    }
}

Testing webhooks to your endpoint

You can test your own webservice, with real webhooks, filtered by a memberId. When using the advanced test functionality an extra field is added. You can use this to filter out test-webhooks in production.

The field added is "isAdvancedTest" and has the value "test".