Compose the API request for an experiment
After you compose a webhook for a triggered experiment, you must compose the API request to include the offer or content returned by a decision model to send to the chosen webhook destination.
The API request enables you to include dynamic data from the guest data model and experiment response. For example, you might want the variant for the triggered experiment to include the guest's first name, location, loyalty number, etc. You configure the request using FreeMarker.
To compose the API request for a triggered experiment:
-
In the API editor, on the API request tab, use the drop-down list to select the external destination you want to send data to.
-
Optionally, to add more headers to the request, click Add headers.
NoteYou can't include FreeMarker variables in the headers that you add here. If you need FreeMarker variables in headers, you have to create them when you're configuring the request to an external destination.
-
If the connection contains FreeMarker variables, click Set variable values to specify a value for every variable. Then, click Save.
NoteWrap string values in double quotes, for example,
"test-value"
. -
Click the API body tab and compose the API request body.
You can include variables by using the FreeMarker variable notation
${}
. For example, you can copy and paste dynamic data from the guest data model and decision model response, as required.Here's an example of the API request body for an abandoned cart email using variables for the guest data model:
RequestResponse{ "from": "[email protected]", "to": "${guest.email}", "subject": "Don't forget your favorite pair of shoes", "body": "Hello, ${guest.firstName}. We noticed that you left a pair of shoes in your cart..." }
-
Click Save.
-
Click to close the API editor.