Transmitting basket data via server side Webhooks

Transmitting basket data via server side Webhooks

Before you start

If you want to transfer Basket data via server side Webhooks, you have two options:

  1. Use the #{BASKET} parameter to have the whole basket transferred as a single URL-encoded JSON string. This is easier to implement, but usually requires more effort on the receiving end.

  2. If you cannot use option 1, then you have the option to access parts of the baskets and send them as ordered lists.

Sending JSON via the #{BASKET} parameter

Let’s say you have the following target URL configured in your Target Configuration:


After the system computed a conversion, it will call the generated target URL:


Beautiful, isn’t it? The given basket is, as mentioned, a URL-encoded string. When encoded (and formatted for readability) it will look like this:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [{ "pid": "6553", "prn": "Shoe", "brn": "Jordan", "pri": "50.00", "qty": "1", "trc": "default", "prc": "shoes" }, { "pid": "12355", "prn": "Shirt", "brn": "Addidas", "pri": "70.00", "qty": "2", "trc": "default", "prc": "shirts" }]

That’s it!

Sending the basket as lists via the #{BASKET_ARRAY} parameters

If, for some reason, you cannot compute JSON on the receiving end, you have the option of sending the basket elements as lists.

The key elements to this method are the two parameters #{BASKET_ARRAY_BEGIN} and #{BASKET_ARRAY_END}. These work in conjunction, and the actual basket parameters you want to receive have to be placed between the two.

The following Parameters are used to declare basket values:

  • BASKET_VALUE_pid → product Id of the basket item

  • BASKET_VALUE_qty → quantity of the basket item

  • BASKET_VALUE_pri → price of the basket item

  • BASKET_VALUE_pri_cents → price of the basket item in cents (without decimals)

  • BASKET_VALUE_prn → product name of the basket item

Let’s look at a simple example:

Let’s say you have the following Target URL configured in your Target Configuration:


Given a conversion with the following basket:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [{ "pid": "6553", "prn": "Shoe", "brn": "Jordan", "pri": "50.00", "qty": "1", "trc": "default", "prc": "shoes" }, { "pid": "12355", "prn": "Shirt", "brn": "Addidas", "pri": "70.00", "qty": "2", "trc": "default", "prc": "shirts" }]

The system would generate the following URL:


Again, URL decoded it would look like this:


You can also define a separator (currently available options are ,;|) on your #{BASKET_ARRAY_BEGIN} declaration:


Would generate (skipping the URL-decode part)



Now let us look at two more complex examples that show you ways to transfer baskets to your system.


Would generate:



As soon as you have created this code, all you need to do is implement it following the instructions in the article on the Webhooks feature.