Promo Code Added via API

🚧

One can send promo codes in trigger letters using this method.

There are 2 general methods of sending letters using API:

  • using the workflow
  • straight on (without using the workflow)

This method allows to create and transfer events to the system. The event will start the workflow, which executed actions programmed in it, for examples, send email or mobile push.

The process looks the following way:

Transferring Events Through API to the System Using

It is necessary to transfer at least channel (email, token, phone number) and promo code in parameters of each event. Event can look like this:

{
  "params": [
    {
      "name": "token",
      "value": "fx19jopCg0VUllNEkYPYoK:APA91bHwrnt1Gs6bt3aokzMsLaxfrpbOIQa3wcRdzGb7JdHqM_g4wSMKKHP9yzdnZ2k_tJrBcmCaOtMmJ2JjPu8uvhpY40-krp7Xav2zugh63pe_Ro2_AmVLcac9KBhUxSB4eRZtMKp4"
    },
    {
      "name": "promocode",
      "value": "ABC-123"
    }
  ]
}

Creating Message for Sending

Insert into the message the name of the variable, which contains promo code.
If you named the variable promocode, $!data.get(‘promocode’) will be inserted in the message.

596

Creating the Workflow

In this case the workflow will look in the following way:

1974

In the parameters choose the message that you want to send. Also it is necessary to indicate parameter from the event, in which mobile token is contained. There is no need to configure something else. In this example block Mobile push is used. If you want to send another channel – use eponymous block and in settings indicate parameter that contains this channel.

Using this method one can send message with promo code straight on, without creating the workflow. This method allows sending promo code to one or many contacts, indicated in the request, but it doesn’t allow sending for group of contacts.

One can transfer individual promo code for each contact.
Format of the body request for this method is:

{
    "recipients": [{
        "locator": "[email protected]",
        "jsonParam": "{\"promocode\":\"ABC-123\"}"
    }],
    "email": true
}

Here recipients – array with addressees. In each of its elements there is jsonParam parameter. It can be used for transferring any data (for example, promo code) in the message. In this parameter the data for message needs to be in JSON format, but transformed to the string.

For sending message by this method you need to create it preliminarily. It needs to contain variable, which will substitute promo code. For current example it is $!data.get('promocode').

In the request api/v1/message/{id}/smartsend instead of {id} put message id, which you want to send.