> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kameleoon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add a goal and segment before launching an experiment

> Link a targeting segment and goal to an experiment, then activate it using the Automation API PATCH endpoint.

## Goal

Link the goal and segment to `Experiment_1` and activate the experiment.

## Steps

### 1. Link and launch

**Endpoint:**

```
PATCH https://api.kameleoon.com/experiments/{experimentId}?action=ACTIVATE
```

| Name               | Type   | Description                                        |
| ------------------ | ------ | -------------------------------------------------- |
| targetingSegmentId | String | Segment ID to link.                                |
| goals              | Array  | Goal IDs to link.                                  |
| deviations         | Object | Traffic allocation between control and variations. |
| mainGoalId         | String | Main goal ID.                                      |
| status             | String | Experiment status (`ONLINE`, `PAUSED`, etc.).      |

**Example:**

```bash theme={null}
curl -L -X PATCH 'https://api.kameleoon.com/experiments/283505?action=ACTIVATE' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
--data-raw '{
  "targetingSegmentId": 298314,
  "goals": [361517],
  "deviations": {"origin": 0.5, "1053310": 0.5},
  "mainGoalId": 361517,
  "status": "ONLINE"
}'
```

### 2. Verify launch

Refresh the dashboard.
`Experiment_1` should now display **Online** status:

<Frame>
  ![Experiment\_activated](https://storage.googleapis.com/kameleoon-storage-documentation/developers/images/api-tutorial/experiment-launched.jpg)
</Frame>

***

Creation, configuration, and launch of an experiment using the Automation API are now complete.
