---
title: Launch experiment
slug: feature-experimentation/api/launch-experiment
docTags: 
createdAt: 2026-09-18T02:54:45.983Z
---

::::CodeDrawer{title="Launch experiment" isResponseExpanded="true" autoGeneratedAnchorSlug="launch-experiment" legacyHash="KFSxGBpi1DXaq5gXuFNKp"}
:::CodeblockTabsExamples
```javascript
// -------------------------------------------------------------------------- //
//                             Launch experiment.                             //
// -------------------------------------------------------------------------- //

// ------------------------------- Enable Flag ------------------------------ //

POST {{flagsUrl}}/projects/{{projectId}}/flags/{{flagKey}}/environments/{{environment}}/ruleset/enabled
Authorization: {{token}}

###

// ---------------------------- Launch Experiment --------------------------- //

PATCH {{flagsUrl}}/projects/{{projectId}}/flags/{{flagKey}}/environments/{{environment}}/ruleset
Content-Type: application/json
Authorization: {{token}}

[{"op":"replace","path":"/rules/stock_message_test/enabled","value":true}]
```
:::

:::CodeblockTabsResponses
```javascript
{"success":true}
```
:::
::::

Use the [Enable the Ruleset for a Flag in an Environment](https://docs.developers.optimizely.com/feature-experimentation/reference/enable_ruleset) API endpoint to launch your A/B test.

## Prerequisite

Before running this request, you must follow the instructions to configure your [REST API cookbook](https://docs.developers.optimizely.com/feature-experimentation/reference/set-up-visual-basic-to-run-rest-api-calls).

## Create a file

Create a file named `launch-experiment.rest` and copy and paste the recipe into the file.

## Enable flag

`{{flagsUrl}}`, `{{projectId}}`, `{{flagKey}}`, `{{environment}}`, and `{{token}}` are defined in the `settings.json` file. Ensure you have configured your Visual Studio Code project correctly. See [Configure the Visual Studio Code REST Client](https://docs.developers.optimizely.com/feature-experimentation/reference/set-up-visual-basic-to-run-rest-api-calls#configure-the-visual-studio-code-rest-client).

Click **Send Request** in Visual Studio Code.

```json
POST {{flagsUrl}}/projects/{{projectId}}/flags/{{flagKey}}/environments/{{environment}}/ruleset/enabled
Authorization: {{token}}
```

## The `###` delimiter

The REST Client extension delimits multiple requests using `###`. See [Main features in the REST Client documentation](https://marketplace.visualstudio.com/items?itemName=humao.rest-client#main-features).

## Launch experiment

`{{flagsUrl}}`, `{{projectId}}`, `{{flagKey}}`, `{{environment}}`, and `{{token}}` are defined in the `settings.json` file. Ensure you have configured your Visual Studio Code project correctly. See [Configure the Visual Studio Code REST Client](https://docs.developers.optimizely.com/feature-experimentation/reference/set-up-visual-basic-to-run-rest-api-calls#configure-the-visual-studio-code-rest-client).

```json
PATCH {{flagsUrl}}/projects/{{projectId}}/flags/{{flagKey}}/environments/{{environment}}/ruleset
Content-Type: application/json
Authorization: {{token}}
```

## Launch experiment body

- **op (operation)** – This is a replace.
- **path** – A JSON-Pointer to the resource or the resource attribute.
- **value** – Replace to `true`.

Click **Send Request** in Visual Studio Code.

```json
[{"op":"replace","path":"/rules/stock_message_test/enabled","value":true}]
```

## Example screenshot

After running the two API requests, your UI should look similar:
