Link Search Menu Expand Document

Voucher issued webhook

Triggered as a result of a voucher being issued for user.

An example of a new voucher webhook

{
    "id": "voucher275221",
    "type": "shopper.voucher-issued",
    "chain_id": 1755,
    "created": "2021-09-22T14:35:45Z",
    "data": {
        "id": 275221,
        "chain_id": 1755,
        "last_modified_date": "2020-03-05T16:09:53Z",
        "created_date": "2020-03-05T16:09:53Z",
        "campaign": {
            "id": 159,
            "chain_id": 1755,
            "last_modified_date": "2017-09-22T08:49:22Z",
            "created_date": "2017-09-22T08:49:22+00:00",
            "campaign_type": "loyalty",
            "image_dimension_x": null,
            "image_dimension_y": null,
            "image_file_name": null,
            "image_link": null,
            "image_url": null,
            "title": "Acme Loyalty Campaign"
        },
        "creating_user": [],
        "currency_code": "EUR",
        "currency_symbol": "€",
        "date_time_creation": "2020-03-05T16:09:53+00:00",
        "date_time_expiry": "2050-01-01T00:00:00+00:00",
        "date_time_redeemed": null,
        "description": null,
        "generating_return_transaction": [],
        "image_dimension_x": null,
        "image_dimension_y": null,
        "image_file_name": null,
        "image_link": null,
        "image_url": null,
        "locking": {
            "locked": false,
            "date_time_locked_until": null,
            "voucher_locking_code": null,
            "voucher_retailer_basket_code_exclusive": null
        },
        "loyalty_rule": {
            "loyalty_rule_id": 9,
            "loyalty_rule_type": "points_tracker"
        },
        "notes": null,
        "product_id": null,
        "product_skus": [],
        "redeemable_channels": [],
        "redeeming_basket": null,
        "spaaza_campaign_promotion": [],
        "status": "generated",
        "task": [],
        "third_party_pos_promotion_id": null,
        "third_party_promotion_id": null,
        "third_party_voucher_code": null,
        "third_party_webshop_promotion_id": null,
        "title": null,
        "user": {
            "id": 3594415,
            "chain_id": 1755,
            "last_modified_date": "2020-11-07T01:10:07Z",
            "created_date": "2020-03-05T16:07:27Z",
            "firstname": "John",
            "lastname": "Smith",
            "country_code": "NL",
            "lang_code": null,
            "gender": "M",
            "signup_store_name": null,
            "spaaza_opted_in": true,
            "birthday": null,
            "last_login_date": "2020-03-05T16:07:27Z",
            "spaaza_join_date": "2020-03-05T16:07:28Z",
            "user_is_new": false,
            "username": "john.smith+20200305_1706@spaaza.com",
            "address": {
                "street_name": null,
                "house_number": null,
                "house_number_extension": null,
                "line_2": null,
                "line_3": null,
                "towncity": null,
                "postal_code": null,
                "address_regionstate": null,
                "phone_number": null
            },
            "printed_mailing_list_subscribed": false,
            "mailing_list_subscribed": false,
            "is_employee": false,
            "language": "en-GB",
            "loyalty_status": {
                "campaign_id": 159,
                "name": "Gold",
                "description": "Level 3 in Acme Programme",
                "loyalty_level_id": 8,
                "points_balance_current": 2100,
                "monetary_balance_current": null,
                "points_to_proceed_next_level": null,
                "points_to_remain_current_level": 0,
                "last_review_date": "2020-03-05T16:07:28+00:00",
                "next_review_date": null,
                "date_reached": "2020-03-05T16:09:53+00:00"
            },
            "signup_channel": "webshop",
            "entity_code": {
                "type": "custom",
                "code": "500027960"
            },
            "authentication_point_identifier": "20079022",
            "last_purchase_date": "2020-03-05T16:21:25Z",
            "online_shopper": true,
            "offline_shopper": false,
            "frequency": 5,
            "recency": 1,
            "monetary": 5,
            "overall": 155,
            "total_cashback_balance": 0,
            "points_wallet_balance": 2100,
            "brands": "",
            "stores": "",
            "last_loyalty_activity_date": "2020-03-05T16:20:30Z",
            "days_since_last_purchase": 565,
            "number_of_purchases": 9,
            "average_spend_value": "295.56",
            "loyalty_status_level": "Gold",
            "attributions": "",
            "push_notification_subscription": {
                "subscribed": false,
                "subscriptions": []
            },
            "auxiliary_identifier": null,
            "referral": {
                "referred": false,
                "referring_user": null,
                "referral_code": "c1qo32",
                "referral_channel": null
            },
            "deleted": false,
            "obfuscated": false,
            "is_influencer": false,
            "registered": true
        },
        "voucher_amount": 25,
        "voucher_amount_redeemed": 0,
        "voucher_deleted": false,
        "voucher_id": 275221,
        "voucher_key": "07ec9f10ebee2714f1d7c1ded8986b90007de09a5cb9d1cc8befb34fe12055cc",
        "voucher_text": "Your Acme loyalty voucher",
        "voucher_type": "basket",
        "voucher_uniqid": "5e61245143a970.70443689",
        "voucher_honour_code": null,
        "voucher_notes": null
    }
}

Spaaza can call an external webhook when a customer voucher is created for a customer.

We can configure a webhook URL that you provide. Whenever the voucher-issued event occurs we send a simple POST request to the URL. The body of the POST is JSON that includes details of the event and the voucher that triggered it. So that you can verify that the POST really originates from Spaaza we provide a signature in a request header (X-Spaaza-Hmac-SHA256).

The value of the header is a base 64 encoded HMAC-SHA256 of the whole body of the request with a shared secret that we would provide. Your code to handle the event should recreate the signature using the shared secret and compare it to the value in the header.