Fetch the Rule for a Ruleset in an Environment
1 min
GET
https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/environments/{environment_key}/rules/{rule_key}
Path Parameters
- project_idintegerrequiredExampleDescription
- flag_keystringrequiredExampleDescription
- environment_keystringrequiredExampleDescription
- rule_keystringrequiredExampleDescription
Responses
200
- RuleDescription
- allow_listmap<string, RuleAllowList>Description
- archivedbooleanDescriptionDefaultfalse
- audience_conditionsobject[]ExampleDescription
- baseline_variation_idintegerDescription
- commentstringDescription
- created_timestring<date-time>ExampleDescriptionFormatdate-time
- custom_fieldsmap<string, string>Description
- deployed_td_rule_audience_conditionsobject[]ExampleDescription
- deployed_td_rule_keystringDescription
- deployed_td_rule_percentage_includedintegerDescriptionDefault0Minimum0Maximum10000
- deployed_variation_keystringDescription
- descriptionstringExampleDescription
- distribution_modestring<manual | stats_accelerator>DescriptionAllowedmanualstats_accelerator
- enabledbooleanDescriptionDefaulttrue
- environment_keystringDescription
- environment_namestringDescription
- fetch_results_ui_urlobjectDescription
- UrlValue
- flag_keystringDescription
- flag_namestringDescription
- group_idstringDescription
- group_remaining_traffic_allocationintegerDescription
- group_ruleRuleGroupRuleExample
{ "id": 73915, "name": "My Group", "traffic_allocation": 5000 }Description- group_idintegerrequiredDescription
- group_namestringDescription
- traffic_allocationintegerDescriptionMinimum0Maximum10000
- hypothesisstringDescriptionMax Length1000
- idintegerExample
- keystringrequiredExample
- layer_experiment_idintegerExample
- layer_idintegerExample
- metricsMetric[]Description
- aggregatorstring<unique | count | sum | ratio>requiredDescriptionAlloweduniquecountsumratio
- display_titlestringDescription
- display_unitstringDescription
- event_idinteger<int64>ExampleDescriptionFormatint64
- event_propertiesobject
- filterobject
- combine_operatorstring<or | and>Allowedorand
- conditionsEventPropertyCondition[]
- namestringrequired
- operatorstring<equal_to | not_equal_to | greater_than | greater_than_or_equal_to | less_than | less_than_or_equal_to | contains | does_not_contain>requiredAllowedequal_tonot_equal_togreater_thangreater_than_or_equal_toless_thanless_than_or_equal_tocontainsdoes_not_contain
- typestring<string | number | boolean>requiredAllowedstringnumberboolean
- valuestringrequired
- event_typestring
- fieldstring<revenue | value>DescriptionAllowedrevenuevalue
- idstringDescription
- metricsSubMetric[]
- aggregatorstring
- display_titlestring
- event_idinteger
- event_typestring
- fieldstring
- rolestring<numerator | denominator>Allowednumeratordenominator
- scopestring
- project_idintegerDescription
- scopestring<session | visitor | event>DescriptionAllowedsessionvisitorevent
- visibilitystring<account | experiment | project>DescriptionAllowedaccountexperimentproject
- winning_directionstring<increasing | decreasing>requiredDescriptionAllowedincreasingdecreasing
- namestringrequiredExample
- outcomestring<positive | negative | inconclusive>DescriptionAllowedpositivenegativeinconclusive
- percentage_includedintegerDescriptionDefault0Minimum0Maximum10000
- statusstring<draft | running | paused | concluded>DescriptionAlloweddraftrunningpausedconcluded
- test_plan_namestringDescriptionMax Length255
- test_plan_typestring<url | file>DescriptionAllowedurlfile
- test_plan_urlstringDescriptionMax Length2000
- typestring<targeted_delivery | a/b | multi_armed_bandit | feature_rollout>requiredDescriptionAllowedtargeted_deliverya/bmulti_armed_banditfeature_rollout
- updated_timestring<date-time>ExampleDescriptionFormatdate-time
- urnstringExampleDescription
- variationsmap<string, RuleVariation>Description
400
401
403
404
curl
curl --request GET \
--url https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/environments/{environment_key}/rules/{rule_key} \
--header 'accept: application/json'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/environments/{environment_key}/rules/{rule_key}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/environments/{environment_key}/rules/{rule_key}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/environments/{environment_key}/rules/{rule_key}"
payload = {}
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
200
// Successful retrieval of a Rule.
{
"allow_list": "",
"archived": false,
"audience_conditions": [
{}
],
"baseline_variation_id": 0,
"comment": "",
"created_time": "2019-05-08T00:00:00.000Z",
"custom_fields": "",
"deployed_td_rule_audience_conditions": [
{}
],
"deployed_td_rule_key": "",
"deployed_td_rule_percentage_included": 0,
"deployed_variation_key": "",
"description": "This rule is used for delivery an experience to paid users",
"distribution_mode": "",
"enabled": false,
"environment_key": "",
"environment_name": "",
"fetch_results_ui_url": {},
"flag_key": "",
"flag_name": "",
"group_id": "",
"group_remaining_traffic_allocation": 0,
"group_rule": {
"group_id": 0,
"group_name": "",
"traffic_allocation": 0
},
"hypothesis": "",
"id": 45633994,
"key": "paid_users",
"layer_experiment_id": 9000000013579,
"layer_id": 9000000013569,
"metrics": [
{
"aggregator": "",
"display_title": "",
"display_unit": "",
"event_id": 32334454244,
"event_properties": {
"filter": {
"combine_operator": "",
"conditions": [
{
"name": "",
"operator": "",
"type": "",
"value": ""
}
]
}
},
"event_type": "",
"field": "",
"id": "",
"metrics": [
{
"aggregator": "",
"display_title": "",
"event_id": 0,
"event_type": "",
"field": "",
"role": "",
"scope": ""
}
],
"project_id": 0,
"scope": "",
"visibility": "",
"winning_direction": ""
}
],
"name": "Paid Users",
"outcome": "",
"percentage_included": 0,
"status": "",
"test_plan_name": "",
"test_plan_type": "",
"test_plan_url": "",
"type": "",
"updated_time": "2019-05-08T00:00:00.000Z",
"urn": "rules.flags.optimizely.com::45633910",
"variations": ""
}400
// Malformed requests and invalid parameter names and types
401
// Invalid credentials
403
// Do not have permission to perform the operation
404
// Not found. No content