---
title: "Compose the API request for an experiment"
slug: "compose-the-api-request-for-an-experiment"
abstract: "Provides details of how to compose the API request for a triggered experiment."
---
# Compose the API request for an experiment

After you [compose a webhook](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-triggered-experiments-in-sitecore-personalize/compose-a-webhook-for-a-triggered-experiment.html "Compose a webhook for a triggered experiment") for a triggered experiment, you must compose the API request to [include the offer or content returned by a decision model](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-triggered-experiments-in-sitecore-personalize/compose-the-api-request-for-an-experiment/use-dynamic-decision-model-data-in-the-api-request-for-a-triggered-experiment.html "Use dynamic decision model data in the API request for a triggered experiment") 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](https://try.freemarker.apache.org/).

To compose the API request for a triggered experiment:

1. 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.
2. Optionally, to add more headers to the request, click **Add headers**.

    > [!note]
    > You 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](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-triggered-experiments-in-sitecore-personalize/connect-sitecore-personalize-to-an-external-destination.html "Connect Sitecore Personalize to an external destination").

3. If the connection contains FreeMarker variables, click **Set variable values** to specify a value for every variable. Then, click **Save**.

    > [!note]
    > Wrap string values in double quotes, for example, `"test-value"`.

4. 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](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-triggered-experiments-in-sitecore-personalize/compose-the-api-request-for-an-experiment/use-guest-data-in-the-api-request-for-a-triggered-experiment.html "Use guest data in the API request for a triggered experiment") and [decision model response](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-triggered-experiments-in-sitecore-personalize/compose-the-api-request-for-an-experiment/use-dynamic-decision-model-data-in-the-api-request-for-a-triggered-experiment.html "Use dynamic decision model data in the API request for a triggered experiment"), as required.

    Here's an example of the API request body for an abandoned cart email using variables for the guest data model:

    ```csharp
    {
      "from": "noreply@myretailsite.com",
      "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..."
    }
    ```

5. Click **Save**.
6. Click ![back.png](https://doc.sitecore.com/api/markdown-image/personalize/en/users/sitecore-personalize/images/back.png) to close the API editor.