Fetch the Ruleset for a Flag in an Environment
1 min
GET
https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/environments/{environment_key}/ruleset
Path Parameters
- project_idintegerrequiredExampleDescription
- flag_keystringrequiredExampleDescription
- environment_keystringrequiredExampleDescription
Responses
200
- RulesetDescription
- archivedbooleanDescription
- default_variation_keystringExampleDescription
- default_variation_namestringExampleDescription
- disable_urlobject
- UrlValue
- enable_urlobject
- UrlValue
- enabledbooleanDescriptionDefaultfalse
- environment_idnumberDescription
- environment_keystringrequiredExampleDescription
- environment_namestringExampleDescription
- fetch_default_variation_urlstringDescription
- fetch_flag_urlobjectDescription
- UrlValue
- flag_keystringrequiredExampleDescription
- idintegerExample
- revisionintegerDescription
- rolestringExampleDescription
- rule_prioritiesstring[]requiredExample
[ "new_users", "paid_users", "trial_users" ]
Description - rulesobject
- RuleMap
- statusstring<draft | running | paused>DescriptionAlloweddraftrunningpaused
- update_urlobject
- UrlValue
- updated_timestring<date-time>ExampleDescriptionFormatdate-time
- urlobjectrequiredDescription
- UrlValue
- urnstringrequiredExampleDescription
400
401
403
404
curl
curl --request GET \
--url https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/environments/{environment_key}/ruleset \
--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}/ruleset", 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}/ruleset")
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}/ruleset"
payload = {}
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
200
// Successful retrieval or update of a Ruleset.
The response includes RESTful JSON (https://restfuljson.org/) styled links. If a
link is not present in the response, it indicates a user is not authorized to access
the related resource.
{
"archived": false,
"default_variation_key": "high_discount",
"default_variation_name": "High Discount",
"disable_url": {},
"enable_url": {},
"enabled": false,
"environment_id": 0,
"environment_key": "production",
"environment_name": "Production",
"fetch_default_variation_url": "",
"fetch_flag_url": {},
"flag_key": "recurring_deposit",
"id": 23456746,
"revision": 0,
"role": "admin",
"rule_priorities": [
""
],
"rules": {},
"status": "",
"update_url": {},
"updated_time": "2019-05-08T00:00:00.000Z",
"url": {},
"urn": "ruleset.flag.optimizely.com::a308d9ae-89ba-11ea-bc55-0242ac130003"
}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