Create a New Experiment
Goal
We’ll create a new experiment, Experiment_1
, as explained in this guide but using the Automation API Create Experiment endpoint.
Requirements
access token
To use the Automation API, you first need an access token.
Follow the instructions in this section to retrieve it programmatically.
-
siteId
-
You can retrieve it directly in your code with the
siteCode
by calling the get a site by code endpoint -
Or log into your Kameleoon account, go to the bottom left corner, and select Projects under the Admin section:
Click Edit on your project:
The
siteId
is the 5-digit number shown in the URL (e.g., 29353): -
Steps
1. Create the Experiment
Endpoint:
POST [https://api.kameleoon.com/experiments](https://api.kameleoon.com/experiments)
Name | Type | Description |
---|---|---|
baseURL | String | URL of the page to load in the Graphic Editor. |
name | String | Experiment name. |
siteId | String | The project’s siteId . |
type | String | Type of experiment (e.g., DEVELOPER for code-based experiments). See API reference. |
Example:
curl -L -X POST 'https://api.kameleoon.com/experiments' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
--data-raw '{"baseURL":"https://test-site.fr/","name":"Experiment_1","siteId":29353,"type":"DEVELOPER"}'
Response:
{
"id": 283505,
"siteId": 29353,
"name": "Experiment_1",
"baseURL": "https://test-site.fr/",
"type": "DEVELOPER",
"status": "draft",
"variations": [1053310],
"isArchived": false
}
2. Verify the Experiment
Go to the Experiments Dashboard and refresh the page.
Experiment_1
should now appear: