Link Search Menu Expand Document

Exporting users (bulk)

curl "-XPOST -v -k \
-H 'X-MyPrice-App-Hostname: retailername.spaaza.com’ \
-H 'Authorization: Bearer <your key>:<your secret>’ \
-d 'export_entity=user’
'https://api0.spaaza.com/auth/export'"

That API end-point will respond with a download link for the CSV file. The link can only be used once and is time limited (currently 48 hours).

[
{
    "result": {
        "code": 1,
        "status": "ok"
    },
    "results": {
        "download_url": "https://services.spaaza.com/export/user?Nonce=2018-03-11T16%3A37%3A21ZAxagGQ9ZmaWBVyFLQZdYsCPWxcmlXoGSWzhCjqKaChA%3D&ChainId=1748&Segment=all",
        "result_type": "spaaza\\api\\auth\\export"
    }
}
]

POST to the API with the post data form encoded and the appropriate headers to specify the app hostname and your credentials.

You can make a GET request to the download link to get the CSV. The link contains a nonce which is signed with a secret known by our API and the download service.

At the moment the download service streams the CSV file over HTTP and it will contain all of the users. A future version will allow you to name a segment of users from the console.

User webhook

An example of a user webhook


{
    "created": "2016-01-08T10:20:35Z",
    "data": {
        "birthday": "1975-07-30",
        "chain_id": 1750,
        "channel": "spaaza-mobile-web",
        "contact_email": "james+nnlive1119@spaaza.com",
        "created": "2016-01-08T10:20:29Z",
        "did_opt_in": true,
        "registered": false,
        "entity_code": "XXX",
        "firstname": "J",
        "gender": "M",
        "lastname": "B",
        "object": "shopper",
        "spaaza_id": 394261,
        "username": "james+nnlive1119@spaaza.com",
        "phone_number": "+31-220445641",
        "address_streetname": "Nieuwe Nieuwstraat",
        "address_housenumber": "104",
        "address_housenumber_extension": "II",
        "address_line_2": "Kleine Buurt",
        "address_line_3": "Centrum",
        "address_towncity": "Hoek van Holland",
        "address_regionstate": "Zuid-Holland",
        "address_postalcode": "1005 AT"
    },
    "id": "568f8d73669bc",
    "object": "event",
    "type": "shopper.opted-in"
}

Spaaza can call external webhooks for certain events, including:

  • when the opt-in status of a user changes
  • when the user is created

We can configure a webhook URL that you provide. Whenever the 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 shopper 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 would need to recreate the signature using the shared secret and compare it to the value in the header.

Status level webhook

An example of a loyalty status level webhook

{
    "type": "shopper.loyalty-level-changed",
    "id": "5b69c11f4bf8c",
    "chain_id": 1743,
    "created": "2018-08-07T15:56:15Z",
    "data": {
        "campaign_id": 201,
        "created_date": "2018-08-07T15:56:15+00:00",
        "id": 80007,
        "log_message": "Manual level change",
        "loyalty_level": {
            "automated_level_logic": true,
            "campaign_id": 201,
            "description": "Silver level in the ACME Programme",
            "id": 4,
            "name": "member"
        },
        "loyalty_level_previous": {
            "automated_level_logic": true
            "campaign_id": 201,
            "description": "Bronze level in the ACME Programme",
            "id": 18,
            "name": "Bronze",
        },
        "mutation_owner_id": 1,
        "user": {
            "address_housenumber": null,
            "address_housenumber_extension": null,
            "address_line_2": null,
            "address_line_3": null,
            "address_postalcode": null,
            "address_regionstate": null,
            "address_streetname": null,
            "address_towncity": null,
            "authentication_point_identifier": "66141993",
            "auxiliary_identifier": "peb209883x",
            "birthday": "1988-05-06T00:00:00+00:00",
            "country_code": "NL",
            "first_name": "Sam",
            "gender": "M",
            "id": 34348394,
            "language": "nl-NL",
            "last_name": "Critchley",
            "loyalty_status": {
                "campaign_id": 201,
                "name": "Silver",
                "description": "Silver level in the ACME Programme",
                "loyalty_level_id": 4,
                "points_balance_current": 340,
                "points_to_proceed_next_level": 410,
                "points_to_remain_current_level": 60,
                "last_review_date": "2019-06-28T09:30:40+00:00",
                "next_review_date": "2020-06-28T09:30:40+00:00",
                "date_reached": "2019-08-23T13:33:15+00:00"
            },
            "mailing_list": {
                "mailing_list_sub_offered": false,
                "mailing_list_subscribed": true,
                "printed_mailing_list_subscribed": false
            },
            "member_number": {
                "code": "30359901",
                "type": "custom"
            },
            "opt_in_programme": {
                "programme_opted_in": true,
                "join_date": "2019-06-06T08:06:14+00:00"
            },
            "opt_in_secondary": false,
            "push_notification_subscription": {
                "subscribed": false,
                "subscriptions": []
            },
            "registered": true,
            "signup_channel": "webshop",
            "user_id": 34348394,
            "username": "acmestage691228534@cowcam.com"
        },

    }
}

Spaaza can call an external webhook when there is a change in a customer’s loyalty level.

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.

Note that the ‘data’ section of the webhook payload includes information about the user whose status has changed and about the new level:

Section Description
loyalty_level Information about the new loyalty level including the name and description of the level.
user Information about the user including their name, member number, email and address information.