Link Search Menu Expand Document

Send a referral notification to somebody

The result output is a JSON array with its results section being something to the lines of the following:

{
    "result": {
        "code": 1,
        "status": "ok"
    },
    "results": {
        "send_notification": {
            "notification": {
                "message": {
                    "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut cursus scelerisque erat id ultricies. Maecenas sit amet ornare ex. Nam massa tellus, feugiat at arcu sit amet, euismod lobortis nunc. Suspendisse mollis pulvinar nunc, sed ultrices lorem fermentum quis. Mauris consequat metus dictum, sollicitudin nulla ut, aliquam erat. Ut quam erat, scelerisque at sodales vel, mollis sit amet ipsum. Vestibulum vel felis risus. Donec cursus pellentesque neque ac tincidunt. Curabitur pellentesque tempus quam sed eleifend. In hac habitasse platea dictumst. Donec vehicula hendrerit imperdiet. Phasellus vitae magna ultrices, porttitor ex et, cursus dui.",
                    "subject": "Use my referral_code"
                },
                "referral_email": "joe.bloggs@example.com",
                "referral_phone_number": "1234567890",
                "referral_type": "email"
            },
            "referring_user": {
                "address_housenumber": null,
                "address_housenumber_extension": null,
                "address_latitude": null,
                "address_line_2": null,
                "address_line_3": null,
                "address_longitude": null,
                "address_postalcode": null,
                "address_regionstate": null,
                "address_streetname": null,
                "address_towncity": null,
                "authentication_point": null,
                "authentication_point_identifier": "23t24ty3464373",
                "auxiliary_identifier": null,
                "average_basket_value": "0.00",
                "country_code": null,
                "days_since_last_purchase": null,
                "entity_code": {
                    "code": "3627395",
                    "type": "regular"
                },
                "first_name": "John",
                "frequency": 0,
                "id": 3627395,
                "is_employee": false,
                "is_influencer": false,
                "language": null,
                "last_name": "Smith",
                "loyalty_status": null,
                "mailing_list": {
                    "mailing_list_sub_offered": false,
                    "mailing_list_subscribed": false,
                    "printed_mailing_list_subscribed": false
                },
                "member_number": "3627395",
                "monetary": 0,
                "number_of_purchases": 0,
                "obfuscated": false,
                "offline_shopper": false,
                "online_shopper": false,
                "opt_in_programme": {
                    "join_date": "2020-04-07T15:41:54+00:00",
                    "programme_opted_in": true
                },
                "opt_in_secondary": null,
                "overall": 0,
                "push_notification_subscription": {
                    "subscribed": false,
                    "subscriptions": []
                },
                "recency": 0,
                "referral_channel": null,
                "referral_code": "h4u8db",
                "referring_user": null,
                "registered": true,
                "signup_channel": "webshop",
                "stores": "",
                "user_id": 3627395,
                "username": "john.smith@spaaza.com"
            }
        },
        "result_type": "send-notification"
    }
}
  • Call name: send-notification
  • Endpoint URL: https://apistage0.spaaza.com/send-notification
  • Request methods: GET
  • Response Content-Type: application/json
  • Auth required: yes

This endpoint allows a referring_user to send a notification to a potential referred_user to join a loyalty programme. A successful response will trigger a notification-webhook webhook or event.

JSON POST Request

The JSON file posted to the API call should be in the following format. Annotation is provided below:

    {
        "entity": {
            "entity_type": "chain",
            "entity_id": 1743
        },
        "referring_user": {
            "user_id": 3627395
        },
        "campaign": {
            "campaign_id": 2098
        },
        "message": {
            "subject": "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...",
            "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut cursus scelerisque erat id ultricies. Maecenas sit amet ornare ex. Nam massa tellus, feugiat at arcu sit amet, euismod lobortis nunc. Suspendisse mollis pulvinar nunc, sed ultrices lorem fermentum quis. Mauris consequat metus dictum, sollicitudin nulla ut, aliquam erat. Ut quam erat, scelerisque at sodales vel, mollis sit amet ipsum. Vestibulum vel felis risus. Donec cursus pellentesque neque ac tincidunt. Curabitur pellentesque tempus quam sed eleifend. In hac habitasse platea dictumst. Donec vehicula hendrerit imperdiet. Phasellus vitae magna ultrices, porttitor ex et, cursus dui."
        },
        "referral_type": "email",
        "referral_email": "joe.bloggs@example",
        "referral_phone_number": "1234567890"
    }                                                                                

JSON request parameters:

Below is a description of the JSON request paramters for the send-notification endpoint:

Field Description
entity (mandatory) Details of the retailer which is submitting the request.
entity_type (mandatory) The type of entity of the retailer. If the retailer is a chain with branches, this will be “chain”. If the retailer is an independent business with a single branch, this will be “business”.
entity_id (mandatory) The Spaaza ID of the retailer entity.
campaign (mandatory) Details of the referral campaign that that referring_user will participate in.
campaign_id (mandatory) The campaign_id of a referral campaign.
referring_user (mandatory for Admin and Privileged authentication) The referring_user is the user who’s referral_code was used by the referred_user during their signup. The referring_user can be identified by either their referral_code, authentication_point_identifier, user_id, username or member_number.
message (mandatory) Details about the message the referring_user is sending.
subject (mandatory) Subject line of the message.
body (mandatory) Body of the message.
referral_type (mandatory) The type of referral messsage.
referral_email or referral_phone_number (at least one must be present) The email address or phone_number of the individual that will receive the message.

Permissions and Authentication

This API call requires a valid Spaaza session. The session can be as follows:

  • Admin authentication: the performing user needs to be logged in and have write access to the chain to which the user is connected.
  • Privileged authentication: the use of privileged authentication is permitted for this endpoint.

Permissions

This API call requires the following permissions scenarios: Write permissions for the entity on behalf of which the call is being made.

Possible error responses

The following represents a list of possible error responses for the send-notification endpoint:

Code Name and Description HTTP Status Code
3 http_vars_missing
This script is missing some required variables which must be submitted.
400
6 no_valid_session
The user needs to be logged in and a valid session key needs to be sent
401
68 permission_denied_or_non_existent
This user has insufficient permissions for this object or the object does not exist.
500
403 campaign_type_not_supported
This type of campaign is not supported
400
154 user_id_invalid
The user_id passed must be an integer up to 10 digits long
400
217 chain_id_not_found
No record has been found for that chain_id
400
228 auth_method_invalid
The given auth_method parameter has an invalid value.
500
405 entity_mismatch
The entities or chains supplied do not match. Unable to find a user matching the chain_id supplied
400
413 campaign_not_found
The campaign was not found
400
403 campaign_type_not_supported
This type of campaign is not supported. The campaign must be a referral campaign
400
264 myprice_app_without_entity
The requested MyPrice app does not have an entity associated with it.
400
265 authorization_invalid
The given authorization header is invalid.
400
267 no_valid_user
A valid username needs to be specified
401
269 no_myprice_app
Myprice app is required
400
270 user_not_found
No user was found
404
416 multiple_parameter_mismatch
Multiple parameters supplied when fewer are required
400
424 access_denied
Access is denied
400