Fetch a single variable definition by its key.
1 min
GET
https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/variable_definitions/{variable_definition_key}
Path Parameters
- project_idintegerrequiredExampleDescription
- flag_keystringrequiredExampleDescription
- variable_definition_keystringrequiredExampleDescription
Responses
200
- VariableDefinition
- default_valuestringrequiredExampleDescription
- descriptionstringExampleDescription
- keystringrequiredExampleDescription
- revisionintegerDescription
- rolestringExampleDescription
- typestring<boolean | string | double | integer | json>requiredExampleDescriptionAllowedbooleanstringdoubleintegerjson
400
401
403
curl
curl --request GET \
--url https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/variable_definitions/{variable_definition_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}/variable_definitions/{variable_definition_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}/variable_definitions/{variable_definition_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}/variable_definitions/{variable_definition_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 single of Variable Definition for a Flag, and Variable Definition Key.
{
"default_value": "0.0",
"description": "This variable is used to configure the amount used for computing the discount",
"key": "amount",
"revision": 0,
"role": "admin",
"type": "double"
}400
// Malformed requests and invalid parameter names and types
401
// Invalid credentials
403
// Do not have permission to perform the operation