Experiment Management API Experiment Endpoints

Name
Description
List List of experiments including their configuration details.
Get details Get the configuration details of an experiment.
List versions List all versions for an experiment.
Get version details Get a specific version for an experiment.
List variants List all variants for an experiment.
Get variant details Get a specific variant for an experiment.
Get variant inclusions Get all inclusions (users) for a variant.
Create variant Create a new variant for an experiment.
Edit variant Edit a variant for an experiment.
Remove variant Remove a variant from an experiment.
Add users to variant Add users to experiment's variant.
Remove users from variant Remove users from experiment's variant.
Remove all users from variant Remove all users from experiment's variant.
Bulk remove users from variant Bulk remove users from experiment's variant.
List deployments List all deployments for an experiment.
Add deployment Add a deployment to an experiment.
Remove deployment Remove a deployment from an experiment.
Edit Edit experiment.
Create Create a new experiment.

List

1GET https://experiment.amplitude.com/api/1/experiments

Fetch a list of experiments including their configuration details. Results are ordered with the most recently created items first.

Query parameters

Name Description
limit The max number of experiments to be returned. Capped at 1000.
cursor The offset to start the "page" of results from.
includeArchived Optional. Boolean. By default it is false. When false, only return active experiments. When true, return active and archived experiments.

Response

A successful request returns a 200 OK response and a list of experiments encoded as JSON in the response body. createdAt and lastModifiedAt are in UTC in ISO 8601 format.

1curl --request GET \
2--url 'https://experiment.amplitude.com/api/1/experiments?limit=1000' \
3--header 'Accept: application/json' \
4--header 'Authorization: Bearer <management-api-key>'

1{
2 "experiments": [
3 {
4 "id": <id>,
5 "projectId": <projectId>,
6 "deployments": [<deploymentId>],
7 "key": "experiment-key",
8 "name": "experiment-name",
9 "decision": null,
10 "decisionReason": null,
11 "description": "description",
12 "enabled": true,
13 "evaluationMode": "remote",
14 "bucketingKey": "amplitude_id",
15 "bucketingSalt": <bucketingSalt>,
16 "bucketingUnit": "User",
17 "variants": [
18 {
19 "key": "control"
20 },
21 {
22 "key": "treatment"
23 }
24 ],
25 "rolledOutVariant": null,
26 "rolloutPercentage": 10,
27 "rolloutWeights": {
28 "control": 1,
29 "treatment": 1
30 },
31 "targetSegments": [
32 {
33 "name": "Segment 1",
34 "conditions": [
35 {
36 "prop": "device_id",
37 "op": "is",
38 "type": "property",
39 "values": [
40 "(none)"
41 ]
42 }
43 ],
44 "percentage": 50,
45 "bucketingKey": "amplitude_id",
46 "rolloutWeights": {
47 "control": 1,
48 "treatment": 1
49 }
50 }
51 ],
52 "stickyBucketing": false,
53 "state": "planning",
54 "startDate": null,
55 "endDate": null,
56 "experimentType": "a-b-test",
57 "createdBy": "abc@amplitude.com",
58 "lastModifiedBy": "abc@amplitude.com",
59 "createdAt":"2022-09-09T15:29:47.940Z",
60 "lastModifiedAt":"2023-01-25T11:43:41.073Z"
61 },
62 "nextCursor": <cursorId>
63 ]
64}

Get details

1GET https://experiment.amplitude.com/api/1/experiments/<id>

Fetch the configuration details of an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.

Response

A successful request returns a 200 OK response and a JSON object with the experiment's details.

1curl --request GET \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

1{
2 "id": <id>,
3 "projectId": <projectId>,
4 "deployments": [<deploymentId>],
5 "key": "experiment-key",
6 "name": "experiment-key",
7 "decision": null,
8 "decisionReason": null,
9 "description": "save button color",
10 "enabled": true,
11 "evaluationMode": "remote",
12 "bucketingKey": "amplitude_id",
13 "bucketingSalt": <bucketingSalt>,
14 "bucketingUnit": "User",
15 "variants": [
16 {
17 "key": "control"
18 },
19 {
20 "key": "treatment"
21 }
22 ],
23 "rolledOutVariant": null,
24 "rolloutPercentage": 0,
25 "rolloutWeights": {
26 "control": 1,
27 "treatment": 1
28 },
29 "targetSegments": [
30 {
31 "name": "Segment 1",
32 "conditions": [
33 {
34 "prop": "city",
35 "op": "is",
36 "type": "property",
37 "values": [
38 "San Francisco"
39 ]
40 }
41 ],
42 "percentage": 0,
43 "bucketingKey": "amplitude_id",
44 "rolloutWeights": {
45 "control": 1,
46 "treatment": 1
47 }
48 }
49 ],
50 "stickyBucketing": false,
51 "state": "running",
52 "startDate": "2023-07-29",
53 "endDate": null,
54 "experimentType": "a-b-test",
55 "deleted": false,
56 "tags": [],
57 "createdBy: "x@amplitude.com"
58}

List versions

1GET https://experiment.amplitude.com/api/1/experiments/{id}/versions

Fetch a list of all versions for an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.

Response

A successful request returns a 200 OK response and a list of experiment's versions encoded as an array of JSON objects in the response body. Versions are sorted in a descending order.

1curl --request GET \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/versions' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

1[
2 {
3 "createdAt": "2023-07-29T03:30:18.427Z",
4 "createdBy": <userId>,
5 "version": 3,
6 "flagConfig": {
7 "id": <id>,
8 "projectId": <projectId>,
9 "deployments": [<deploymentId>],
10 "key": "experiment-key",
11 "name": "experiment-key",
12 "description": "save button color",
13 "enabled": true,
14 "bucketingKey": "amplitude_id",
15 "variants": [
16 {
17 "key": "control"
18 },
19 {
20 "key": "treatment"
21 }
22 ],
23 "rolloutWeights": {
24 "control": 1,
25 "treatment": 1
26 },
27 "targetSegments": [
28 {
29 "name": "Segment 1",
30 "conditions": [
31 {
32 "prop": "city",
33 "op": "is",
34 "type": "property",
35 "values": [
36 "San Francisco"
37 ]
38 }
39 ],
40 "percentage": 0,
41 "bucketingKey": "amplitude_id",
42 "rolloutWeights": {
43 "control": 1,
44 "treatment": 1
45 }
46 }
47 ],
48 "stickyBucketing": false,
49 "state": "decision-made",
50 "startDate": "2023-07-29",
51 "endDate": "2023-07-29",
52 "experimentType": "a-b-test"
53 }
54 },
55 {
56 "createdAt": "2023-07-29T03:26:23.603Z",
57 "createdBy": <userId>,
58 "version": 2,
59 "flagConfig": {
60 "id": <id>,
61 "projectId": <projectId>,
62 "deployments": [],
63 "key": "experiment-key",
64 "name": "experiment-key",
65 "description": "save button color",
66 "enabled": false,
67 "bucketingKey": "amplitude_id",
68 "variants": [
69 {
70 "key": "control"
71 },
72 {
73 "key": "treatment"
74 }
75 ],
76 "rolloutWeights": {
77 "control": 1,
78 "treatment": 1
79 },
80 "targetSegments": [],
81 "stickyBucketing": false,
82 "state": "planning",
83 "startDate": null,
84 "endDate": null,
85 "experimentType": "a-b-test"
86 }
87 },
88 {
89 "createdAt": "2023-07-29T03:25:42.236Z",
90 "createdBy": <userId>,
91 "version": 1,
92 "flagConfig": {
93 "id": <id>,
94 "projectId": <projectId>,
95 "deployments": [],
96 "key": "experiment-key",
97 "name": "experiment-key",
98 "description": "",
99 "enabled": false,
100 "bucketingKey": "amplitude_id",
101 "variants": [
102 {
103 "key": "control"
104 },
105 {
106 "key": "treatment"
107 }
108 ],
109 "rolloutWeights": {
110 "control": 1,
111 "treatment": 1
112 },
113 "targetSegments": [],
114 "stickyBucketing": false,
115 "state": "planning",
116 "startDate": null,
117 "endDate": null,
118 "experimentType": "a-b-test"
119 }
120 }
121]

Get version details

1GET https://experiment.amplitude.com/api/1/experiments/{id}/versions/{versionId}

Fetch details of a specific version of an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.
versionId Required. String. The version's ID.

Response

A successful request returns a 200 OK response and a JSON object with details of the version.

1curl --request GET \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/versions/<versionId>' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

1{
2 "createdAt": "2023-07-29T03:30:18.427Z",
3 "createdBy": <userId>,
4 "version": 3,
5 "flagConfig": {
6 "id": <id>,
7 "projectId": <projectId>,
8 "deployments": [<deploymentId>],
9 "key": "experiment-key",
10 "name": "experiment-key",
11 "description": "save button color",
12 "enabled": true,
13 "bucketingKey": "amplitude_id",
14 "variants": [
15 {
16 "key": "control"
17 },
18 {
19 "key": "treatment"
20 }
21 ],
22 "rolloutWeights": {
23 "control": 1,
24 "treatment": 1
25 },
26 "targetSegments": [
27 {
28 "name": "Segment 1",
29 "conditions": [
30 {
31 "prop": "city",
32 "op": "is",
33 "type": "property",
34 "values": [
35 "San Francisco"
36 ]
37 }
38 ],
39 "percentage": 0,
40 "bucketingKey": "amplitude_id",
41 "rolloutWeights": {
42 "control": 1,
43 "treatment": 1
44 }
45 }
46 ],
47 "stickyBucketing": false,
48 "state": "decision-made",
49 "startDate": "2023-07-29",
50 "endDate": "2023-07-29",
51 "experimentType": "a-b-test"
52 }
53}

List variants

1GET https://experiment.amplitude.com/api/1/experiments/{id}/variants

Fetch a list of all variants for an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.

Response

A successful request returns a 200 OK response and a list of variants encoded as an array of JSON objects in the response body.

1curl --request GET \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

1[
2 {
3 "key": "control",
4 "name": "",
5 "payload": {},
6 "description": "",
7 "rolloutWeight": 1
8 },
9 {
10 "key": "treatment",
11 "name": "",
12 "payload": {},
13 "description": "",
14 "rolloutWeight": 1
15 }
16]

Get variant details

1GET https://experiment.amplitude.com/api/1/experiments/{id}/variants/{variantKey}

Fetch details of a specific variant of an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.
variantKey Required. String. The variant's key.

Response

A successful request returns a 200 OK response and a JSON object with details of experiment variant.

1curl --request GET \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants/<variantKey>' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

1{
2 "key": "control",
3 "name": "",
4 "payload": {},
5 "description": "",
6 "rolloutWeight": 1
7}

Get variant inclusions

1GET https://experiment.amplitude.com/api/1/experiments/{id}/variants/{variantKey}/users

Fetch a list of inclusions for a specific variant of an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.
variantKey Required. String. The variant's key.

Response

A successful request returns a 200 OK response and a list of inclusions of experiment's variant as an array of JSON objects.

1curl --request GET \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants/<variantKey>/users' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

1[
2 <user>@<your-company-email>,
3 <userId>
4]

Create variant

1POST https://experiment.amplitude.com/api/1/experiments/{id}/variants

Create a new variant for an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.

Request body

Name
Requirement Type Description
key Required string The variant key.
description Optional string Description for the variant.
name Optional string Name for the variant.
payload Optional string Optional payload. Value must be a valid JSON element.
rolloutWeight Optional number Rollout weight for non-targeted users.

Request

1{
2 "key": "new-variant-key",
3 "description": "optional description for variant",
4 "name": "optional name for variant",
5 "payload": {"variant-payload": "example payload"},
6 "rolloutWeight": 0
7}

Response

A successful request returns a 200 OK response and OK text.

Example request

1curl --request POST \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants' \
3 --header 'Content-Type: application/json' \
4 --header 'Accept: application/json' \
5 --header 'Authorization: Bearer <management-api-key>' \
6 --data '{"key":"<key>","name":"<name>","description":"<description>","payload":"<payload>","rolloutWeight":<rolloutWeight>}'

Edit variant

1PATCH https://experiment.amplitude.com/api/1/experiments/<id>/variants/<variantKey>

Edit a variant for an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.
variantKey Required. String. The variant's key.

Request body

Name
Requirement Type Description
key Optional string The variant key.
description Optional string Description for the variant.
name Optional string Name for the variant.
payload Optional string Optional payload. Value must be a valid JSON element. This value replaces the existing value for the variant payload.
rolloutWeight Optional number Rollout weight for non-targeted users.

Example request

1{
2 "key": "updated-variant-key",
3 "description": "updated-optional description for variant",
4 "name": "optional name for variant",
5 "payload": {"variant-payload": "example payload"},
6 "rolloutWeight": 10
7}

Response

A successful request returns a 200 OK response and OK text.

Request

1curl --request PATCH \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants/<variantKey>' \
3 --header 'Content-Type: application/json' \
4 --header 'Accept: application/json' \
5 --header 'Authorization: Bearer <management-api-key>' \
6 --data '{"key":"<key>","name":"<name>","description":"<description>","payload":"<payload>","rolloutWeight":<rolloutWeight>}'

Remove variant

1DELETE https://experiment.amplitude.com/api/1/experiments/{id}/variants/{variantKey}

Remove a variant from an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.
variantKey Required. String. The variant's key.

Response

A successful request returns a 200 OK response and OK text.

Request

1curl --request DELETE \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants/<variantKey>' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

Add users to variant

1POST https://experiment.amplitude.com/api/1/experiments/{id}/variants/{variantKey}/users

Add inclusions (users or devices) to experiment's variant.

Path variables

Name Description
id Required. String. Experiment's ID.
variantKey Required. String. The variant's key.

Example request

1{
2 "inclusions": [<user1>@<your-company-email>, <user2>@<your-company-email>, <userId>]
3}

Request body

Name
Requirement Type Description
inclusions Required object Contains an string array of user or device ids.

Response

A successful request returns a 200 OK response and OK text.

Request

1curl --request POST \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants/<variantKey>/users' \
3 --header 'Content-Type: application/json' \
4 --header 'Accept: application/json' \
5 --header 'Authorization: Bearer <management-api-key>' \
6 --data '{"inclusions":<["id1", "id2", "id3"]>}'

Remove users from variant

1DELETE https://experiment.amplitude.com/api/1/experiments/{id}/variants/{variantKey}/users/{userIndex}

Remove inclusions (users or devices) from experiment's variant.

Path variables

Name Description
id Required. String. Experiment's ID.
variantKey Required. String. The variant's key.
userIndex Required. String. The user's index. Zero-indexed. Index-based array of users can be obtained via Get variant inclusions

Response

A successful request returns a 200 OK response and OK text.

Request

1curl --request DELETE \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants/<variantKey>/users/<userIndex>' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

Remove all users from variant

1DELETE https://experiment.amplitude.com/api/1/experiments/{id}/variants/{variantKey}/users

Remove all inclusions (users or devices) from experiment's variant.

Path variables

Name
Description
id Required. String. The object's ID.
variantKey Required. String. The variant's key.

Response

A successful request returns a 200 OK response and OK text.

Request

1curl --request DELETE \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants/<variantKey>/users' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

Bulk remove users from variant

1DELETE https://experiment.amplitude.com/api/1/experiments/{id}/variants/{variantKey}/bulk-delete-users

Bulk remove users or devices from experiment's variant. Limited to 100 per request.

Path variables

Name
Description
id Required. String. The object's ID.
variantKey Required. String. The variant's key.

Request body

Name
Requirement Type Description
users Required object Contains an string array of user or device ids.

Response

A successful request returns a 200 OK response and OK text.

Request

1curl --request DELETE \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/variants/<variantKey>/bulk-delete-users' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>' \
5 --data '{"users":<["id1", "id2", "id3"]>}'

List deployments

1GET https://experiment.amplitude.com/api/1/experiments/{id}/deployments

List all deployments for an experiment.

Path variables

Name
Description
id Required. String. Experiment's ID.

Response

A successful request returns a 200 OK response and an array of JSON objects with experiment's deployment details.

1curl --request GET \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/deployments' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

1[
2 {
3 "id": <id>,
4 "projectId": <projectId>,
5 "label": "rest-api",
6 "key": <key>,
7 "deleted": false
8 }
9]

Add deployment

1POST https://experiment.amplitude.com/api/1/experiments/{id}/deployments

Add a deployment to an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.

Request body

Name
Requirement Type Description
deployments Required object Contains an string array of deployment ids.

Example request

1{
2 "deployments": ["<deploymentId>"]
3}

Response

A successful request returns a 200 OK response and OK text.

Request

1curl --request POST \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/deployments' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'
5 --data '{"deployments":[<deploymentId>]}'

Remove deployment

1DELETE https://experiment.amplitude.com/api/1/experiments/{id}/deployments/{deploymentId}

Remove a deployment from an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.
deploymentId Required. String. The deployment's ID.

Response

A successful request returns a 200 OK response and OK text.

Request

1curl --request DELETE \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>/deployments/<deploymentId>' \
3 --header 'Accept: application/json' \
4 --header 'Authorization: Bearer <management-api-key>'

Edit

Note

Web Experimentation doesn't support the editing of experiments. Attempts to edit a web experiment return a 501 error.

1PATCH https://experiment.amplitude.com/api/1/experiments/{id}

Edit an experiment.

Path variables

Name Description
id Required. String. Experiment's ID.

Request body

Name
Requirement Type Description
name Optional string Name.
description Optional string Description.
bucketingKey Optional string The user property to bucket the user by.
bucketingSalt Optional string Bucketing salt.
bucketingUnit Optional string Bucketing unit represented by a group type from the accounts add-on. Used for group level bucketing and analysis.
evaluationMode Optional string Evaluation mode for the experiment, either local or remote.
rolloutPercentage Optional number Rollout percentage for non-targeted users. Range 0 - 100.
targetSegments Optional object See the targetSegments table for more information. When targetSegments object is provided, it will replace existing target segments. Note: cohorts are not supported at the moment.
enabled Optional boolean Property to activate or deactivate experiment.
archive Optional boolean Property to archive or unarchive experiment.
experimentType Optional string Experiment type, options include a-b-test or multi-arm-bandit.
stickyBucketing Optional boolean If true, the experiment uses sticky bucketing.
startDate Optional string Start date of the experiment in ISO 8601 format.
endDate Optional string End date of the experiment in ISO 8601 format. End date can be null.
exposureEvent Optional object See the exposureEvent table for more information. If set to null, the Amplitude Exposure Event will be used.
tags Optional string array A list of tags for the experiment. Tags are added and deleted by the same operation. If you would like to add new tags to the existing ones, you should fetch a list of all experiment tags first.

exposureEvent

Name
Requirement Type Description
event_type Required string Event type.
filters Required object array A list of property filters. See the filters table for more information.

filters

Name
Requirement Type Description
group_type Optional string Group type of the filter; can be null. Can be User value or one of the group values, eg org _id, org name
subprop_key Required string Filter's key; can be null.
subprop_op Required string The operation to use in this filter.
subprop_type Required string Either event, user or group indicating that the property is either an event, user or group property, respectively.
subprop_value Required string array A list of values to filter the event property by.

subprop_op

  • is
  • is not
  • contains
  • does not contain
  • less
  • less or equal
  • greater
  • greater or equal
  • glob match
  • glob does not match

Example request

1{
2 "name": "updated name",
3 "description": "updated description",
4 "bucketingKey": "amplitude_id",
5 "bucketingSalt": "<bucketingSalt>",
6 "evaluationMode": "remote",
7 "rolloutPercentage": 0,
8 "enabled": true,
9 "experimentType": "a-b-test",
10 "stickyBucketing": false,
11 "startDate": "2023-07-31T10:26:00.996Z",
12 "endDate": "2023-09-23T10:26:00.996Z",
13 "tags": ["prod", "staging"],
14 "exposureEvent": {
15 "event_type": "_active",
16 "filters": [
17 {
18 "group_type": "User",
19 "subprop_key": "amplitude_day_of_week",
20 "subprop_op": "is",
21 "subprop_type": "day_time_prop",
22 "subprop_value": [
23 "Tuesday"
24 ]
25 }
26 ]
27 }
28}

Response

A successful request returns a 200 OK response.

Request

1curl --request PATCH \
2 --url 'https://experiment.amplitude.com/api/1/experiments/<id>' \
3 --header 'Content-Type: application/json' \
4 --header 'Accept: application/json' \
5 --header 'Authorization: Bearer <management-api-key>' \
6 --data '{"enabled":<enabled>,"rolloutPercentage":<rolloutPercentage>}'

Create

1POST https://experiment.amplitude.com/api/1/experiments

Create a new feature experiment.

Request body

Name
Requirement Type Description
projectId Required string The project's ID.
key Required string The experiment key.
name Optional string The experiment name.
description Optional string Description for the experiment.
variants Optional object array Array of variants.
bucketingKey Optional string The user property to bucket the user by.
rolloutWeights Optional object Rollout weights for non-targeted users. The object should be a mapping from variant key to rollout weight as an integer. For example: { "control": 1, "treatment": 1 }.
targetSegments Optional object See the targetSegments table for more information.
deployments Optional string array Array of deployments that the experiment should be assigned to.
evaluationMode Optional string Experiment evaluation mode; options include remote or local.
experimentType Optional string Experiment type; options include a-b-test or multi-arm-bandit.

variants

The variants field contains these objects.

Name
Requirement Type Description
key Required string The key (a.k.a value) of the variant.
payload Optional string Optional payload. Value must be a valid JSON element.
name Optional string The variant name.
description Optional string The variant description.

targetSegments

The targetSegments field contains these objects.

Name
Requirement Type Description
name Required string The segment name.
conditions Required object array Array of conditions.
percentage Required number The allocation percentage for users who match a condition.
rolloutWeights Required object A map from variant key to rollout weight. For example: { "control": 1, "treatment": 1 }.

conditions

The conditions field contains these objects.

Name
Requirement Type Description
type Required string Must have value: property
prop Required string The property to use in the condition. Prefix custom and free-form properties with gp:
op Required string The operation to use in this condition.
values Required string array The values to use in the operation.

op

A string value representing operations on a property value. Possible values are:

  • is
  • is not
  • contains
  • does not contain
  • less
  • less or equal
  • greater
  • greater or equal
  • set is
  • set is not
  • set contains
  • set does not contain
  • glob match
  • glob does not match

Example request

1{
2 "projectId":"<projectId>",
3 "name": "Analyze button clicks experiment",
4 "key": "analyze-button-clicks-experiment",
5 "description": "analyze button clicks on the main page",
6 "variants": [
7 {
8 "key": "control"
9 },
10 {
11 "key": "treatment"
12 }
13 ],
14 "rolloutWeights": {"control": 1, "treatment": 1},
15 "targetSegments": [
16 {
17 "name": "Segment 1",
18 "conditions": [
19 {
20 "prop": "country",
21 "op": "is",
22 "type": "property",
23 "values": [
24 "United States"
25 ]
26 }
27 ],
28 "percentage": 0,
29 "bucketingKey": "amplitude_id",
30 "rolloutWeights": {
31 "control": 1,
32 "treatment": 1
33 }
34 }
35 ],
36 "deployments": ["<deploymentId>"],
37 "evaluationMode": "remote",
38 "experimentType": "a-b-test"
39}

Response

A successful request returns a 200 OK response and a JSON object with the experiment's id and url.

1curl --request POST \
2 --url 'https://experiment.amplitude.com/api/1/experiments' \
3 --header 'Content-Type: application/json' \
4 --header 'Accept: application/json' \
5 --header 'Authorization: Bearer <management-api-key>' \
6 --data '{"projectId":"<projectId>","key":"<key>"}'

1{
2 "id": "<id>",
3 "url": "http://experiment.amplitude.com/amplitude/<projectId>/config/<id>"
4}

Was this page helpful?

Thanks for your feedback!

June 4th, 2024

Need help? Contact Support

Visit Amplitude.com

Have a look at the Amplitude Blog

Learn more at Amplitude Academy

© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.