---
title: "Compose the API request for a web experiment"
slug: "compose-the-api-request-for-a-web-experiment"
abstract: "Provides details of how to compose the API request to return custom data."
---
# Compose the API request for a web experiment

When you compose the API request, you must enter the parameters that your organization's website requires in order to correctly display the offer or content. You can [copy and paste dynamic data from the web experiment response](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/compose-the-api-request-for-a-web-experiment/use-dynamic-experiment-data-in-the-api-request.html "Use dynamic experiment data in the API request") into the API request. This is required if you want to use any parameters in the API request that are requested by the dependent website, such as `"uri"`, `"region"`, and `"pointOfSale"`.

You can also [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-web-experiments-in-sitecore-personalize/compose-the-api-request-for-a-web-experiment/use-dynamic-decision-model-data-in-the-api-request.html "Use dynamic decision model data in the API request") in the API request.

To do this, you must configure the variant to include the dynamic data so that when the variant executes, the server requests the dynamic data and passes it to your organization's website.

To compose the API request for a web experiment:

1. In the code editor, click the **API** tab.
2. Compose the API request using FreeMarker.

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

3. You must then reference this data again by pasting it into the relevant [HTML](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/create-a-web-experiment/use-html-in-a-web-experiment.html "Use HTML in a web experiment"), [CSS](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/create-a-web-experiment/use-css-in-a-web-experiment.html "Use CSS in a web experiment"), or [JavaScript](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/create-a-web-experiment/use-javascript-in-a-web-experiment.html "Use JavaScript in a web experiment") editor.
4. Click **Save**.
5. Click ![back.png](https://doc.sitecore.com/api/markdown-image/personalize/en/users/sitecore-personalize/images/back.png) to close the code editor.

> [!note]
> If you use an out-of-the-box web template, or if you have copied the JavaScript from such a template, you must reference an attribute from the API response within a `context` object. For example, to include in the CSS an `imageURL` from the API response, reference it as follows:
>
> background-image: url(“{{context.imageURL}}”)