Experiments
For instructions on how to authenticate to use this endpoint, see API overview.
Endpoints
GET | |
POST | |
GET | |
PATCH | |
DELETE | |
GET | |
POST | |
POST | |
POST | |
POST | |
POST | |
GET | |
GET | |
POST | |
POST | |
POST | |
GET | |
GET | |
POST |
List all experiments
List experiments for the current project. Supports filtering by status and archival state.
Required API key scopes
experiment:readQuery parameters
- archivedboolean
- created_by_idstring
- eventstring
- feature_flag_idinteger
- limitinteger
- offsetinteger
- orderstring
- prompt_namestring
- searchstring
- statusstringOne of:
"all""complete""draft""exposure_frozen""paused""running""stopped"
Response
Example request
GET /api/projects/:project_id/experiments Example response
Status 200
Create experiments
Also available via the PostHog MCP server:
experiment-create— Create experiment
Create a new experiment in draft status with optional metrics.
Required API key scopes
experiment:writeRequest parameters
- namestring
- descriptionstringnull
- start_datestringnull
- end_datestringnull
- feature_flag_keystring
- feature_flag
- holdout_idintegernull
- parameters
- running_time_calculation
- excluded_variantsarraynull
- secondary_metrics
- saved_metrics_idsarraynull
- filters
- archivedbooleanDefault:
false - deletedbooleannull
- type
- exposure_criteria
- metrics
- metrics_secondary
- stats_config
- scheduling_config
- allow_unknown_eventsbooleanDefault:
false - _create_in_folderstring
- conclusion
- conclusion_commentstringnull
- repositorystringnull
- primary_metrics_ordered_uuids
- secondary_metrics_ordered_uuids
- only_count_matured_usersboolean
- update_feature_flag_paramsbooleanDefault:
false - versionintegernull
- original_experimentobjectnull
Response
Example request
POST /api/projects/:project_id/experiments Example response
Status 201
Retrieve experiments
Also available via the PostHog MCP server:
experiment-get— Get experiment details
Retrieve a single experiment by ID, including its current status, metrics, feature flag, and results metadata.
Required API key scopes
experiment:readPath parameters
- idinteger
Response
Example request
GET /api/projects/:project_id/experiments/:id Example response
Status 200
Update experiments
Also available via the PostHog MCP server:
experiment-update— Update experiment
Update an experiment. Use this to modify experiment properties such as name, description, metrics, variants, and configuration. Metrics can be added, changed and removed at any time. Feature-flag config (variants, rollout, payloads) is sent via the feature_flag object.
Required API key scopes
experiment:writePath parameters
- idinteger
Request parameters
- namestring
- descriptionstringnull
- start_datestringnull
- end_datestringnull
- feature_flag_keystring
- feature_flag
- holdout_idintegernull
- parameters
- running_time_calculation
- excluded_variantsarraynull
- secondary_metrics
- saved_metrics_idsarraynull
- filters
- archivedbooleanDefault:
false - deletedbooleannull
- type
- exposure_criteria
- metrics
- metrics_secondary
- stats_config
- scheduling_config
- allow_unknown_eventsbooleanDefault:
false - _create_in_folderstring
- conclusion
- conclusion_commentstringnull
- repositorystringnull
- primary_metrics_ordered_uuids
- secondary_metrics_ordered_uuids
- only_count_matured_usersboolean
- update_feature_flag_paramsbooleanDefault:
false - versionintegernull
- original_experimentobjectnull
Response
Example request
PATCH /api/projects/:project_id/experiments/:id Example response
Status 200
Delete experiments
Hard delete of this model is not allowed. Use a patch API call to set "deleted" to true
Required API key scopes
experiment:writePath parameters
- idinteger
Example request
DELETE /api/projects/:project_id/experiments/:id Example response
Status 405 No response body
Retrieve experiments activity
Change history for this experiment.
Returns a paginated audit trail of changes to the experiment and its holdouts and shared metrics: who made each change, what changed (field-level before/after values), and when. Ordered newest first.
Required API key scopes
activity_log:readPath parameters
- idinteger
Query parameters
- limitintegerDefault:
10 - pageintegerDefault:
1
Response
Example request
GET /api/projects/:project_id/experiments/:id/activity Example response
Status 200
Status 404 No response body
Create experiments archive
Archive an ended experiment.
Hides the experiment from the default list view. The experiment can be restored at any time by updating archived=false. When the linked feature flag is still enabled, pass disable_feature_flag=true to also disable and archive it. Returns 400 if the experiment is already archived or has not ended yet.
Required API key scopes
experiment:writePath parameters
- idinteger
Request parameters
- disable_feature_flagbooleanDefault:
false
Response
Example request
POST /api/projects/:project_id/experiments/:id/archive Example response
Status 200
Create experiments copy to project
Copy an experiment into another project in the same organization as a new draft.
Required API key scopes
experiment:writePath parameters
- idinteger
Request parameters
- target_team_idinteger
- feature_flag_keystring
- namestring
Response
Example request
POST /api/projects/:project_id/experiments/:id/copy_to_project