Skip to main content
This guide explains how to retrieve the JavaScript and CSS code from winning variations of Developer (code-based) experiments that were paused or stopped since 2026. To retrieve the code, complete the following steps:
  1. Build the filter to retrieve code-based experiments that were paused or stopped since 2026.
  2. Retrieve the filtered experiments using the Get all experiments endpoint.
  3. Identify the winning variation by retrieving the experiment results.
  4. Retrieve the JS and CSS code using the Get a variation endpoint.
You can also find a complete Python script implementing the workflow at the end of this guide.

Prerequisites

Before you use the Automation API, ensure that you have an access token. To obtain a token, see the Authentication guide.

Build the filter

To filter experiments, use the filter query parameter. Filter the experiments based on the following criteria:
  • status: Set to PAUSED or STOPPED.
  • dateStatusModified: Set to greater than January 1, 2026.
  • type: Set to DEVELOPER.

Example filter

To generate a valid filter directly from the Experiment dashboard:
  1. Open your Experiment dashboard.
  2. Apply the desired filters using the dashboard UI.
  3. Open your browser’s Developer Tools.
  4. Go to the Network tab.
  5. Search for the GetExperiments request.
  6. Open the corresponding GraphQL request and select the Payload tab.
You can copy the exact filter configuration generated by the interface and reuse it in the Automation API.
GraphQL filter example

Retrieve the filtered experiments

Pass the filter as a URL query parameter. Percent-encode the JSON filter before you add it to the URL.

Example request

Example response

From this response, note the following fields for the next steps:
  • id: The experiment ID.
  • mainGoalId: Required to retrieve the experiment results.
  • variations: The list of variation IDs.

Find the winning variation

To identify the winning variation, complete the following steps:
  1. Retrieve the experiment results. For more information, see Retrieve experiment results.
  2. Include the mainGoalId from the previous response.
  3. Compare the improvementRate for each variation.

Example request

Response

After submitting the request, you will receive a data code. Use this code to retrieve the results. For more information, see the retrieve experiment results guide.

Identify the winner

In the response data, locate the goalsData for each variation ID (for example, 1199120 and 1199121), ignoring the _reference (baseline) variation. Compare the improvementRate of each variation. The variation with the highest positive improvementRate is the winner. In this example:
  • 1199120 has an improvementRate of 26.57.
  • 1199121 has an improvementRate of -15.5.
Therefore, the winning variation is 1199120.

Retrieve the JS and CSS code

You can find experiment-level code in the following fields from your initial experiment response:
  • commonJavaScriptCode
  • commonCssCode
  • globalScript (custom experiment script)
To retrieve the variation-level code, use the Get a variation endpoint.

Example request

Example response

Locate the code

You can find the variation-level code in the following fields:
  • JavaScript code: jsCode
  • CSS code: cssCode

Complete Python script

The following script automates the full workflow to build the filter, retrieve the experiments, find the winning variation, and extract the code.