Skip to main content

Create a new experiment

Goal

Create a new experiment, Experiment_1, as explained in the graphic editor guide using the Automation API Create Experiment endpoint.

Requirements

  • access token

The Automation API requires an access token. Retrieve the token programmatically by following the instructions in the obtaining an access token section.

  • siteId

    • Retrieve the siteId directly in code with the siteCode by calling the get a site by code endpoint.

    • Alternatively, log into the Kameleoon account, navigate to the bottom-left corner, and select Projects under the Admin section:

    SiteID

    Click Edit on the project:

    Edit

    The siteId is the five-digit number in the URL (for example, 29353):

    Digits

Steps

1. Create the experiment

Endpoint:


POST [https://api.kameleoon.com/experiments](https://api.kameleoon.com/experiments)

NameTypeDescription
baseURLStringURL of the page to load in the Graphic Editor.
nameStringExperiment name.
siteIdStringThe project’s siteId.
typeStringType of experiment (for example, 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:

Experiment1