Create a New Flag
1 min
POST
https://api.optimizely.com/flags/v1//projects/{project_id}/flags
Path Parameters
- project_idintegerrequiredExampleDescription
Body Parameters
- bodyFlagRequestBodyrequired
- descriptionstringExample
- is_permanentbooleanDescriptionDefaultfalse
- keystringrequiredExample
- namestringExample
- outlier_filtering_enabledbooleanDefaultfalse
- owner_user_idstringExampleDescription
- team_idsstring[]Example
[ "1234567890", "0987654321" ]
DescriptionDefault - variable_definitionsmap<string, VariableDefinition>Example
{ "advanced": { "default_value": "{\n\t\"hello\": 123\n}", "description": "This variable is used to configure the advanced used for advanced purposes", "key": "advanced", "type": "json" }, "amount": { "default_value": "0.0", "description": "This variable is used to configure the amount used for computing the discount", "key": "amount", "type": "double" }, "message": { "default_value": "Use recurring deposits to compound interest", "description": "This variable is used to configure the message used for displaying the discount", "key": "message", "type": "string" } }
Responses
201
- FlagExample
{ "account_id": 12345, "archive_url": "...", "archived": false, "created_by_user_id": "[email protected]", "created_time": "2019-05-08T00:00:00.000Z", "delete_url": "string", "description": "Flag used for driving customers to use recurring deposits by showing a graph of compound interest over time", "environments": { "development": { "disable_url": "...", "enable_url": "...", "enabled": false, "key": "development", "name": "Development", "priority": 2, "rules_summary": [ { "audience_ids": [ 1 ], "created_time": "2022-01-08T00:00:00.000Z", "days_running": 30, "enabled": true, "key": "a/b", "name": "A/B Test", "primary_metric": "conversion_rate", "traffic_allocation": 100, "type": "experiment", "updated_time": "2022-01-08T00:00:00.000Z" } ] }, "production": { "disable_url": "...", "enable_url": "...", "enabled": false, "key": "production", "name": "Production", "priority": 1, "rules_detail": [ { "audience_ids": [ 1 ], "created_time": "2022-01-08T00:00:00.000Z", "days_running": 30, "enabled": true, "id": 123, "key": "a/b", "name": "A/B Test", "primary_metric": "conversion_rate", "traffic_allocation": 100, "type": "experiment", "updated_time": "2022-01-08T00:00:00.000Z" } ], "rules_summary": { "a/b": { "keys": [ "new_users" ] }, "targeted_delivery": { "keys": [ "paid_users", "trial_users" ] } } } }, "id": 45633994, "key": "recurring_deposit", "name": "Recurring Deposit", "outlier_filtering_enabled": false, "project_id": 12345, "revision": 1, "unarchive_url": "...", "update_url": "...", "updated_time": "2019-05-08T00:00:00.000Z", "url": "...", "urn": "flags.flag.optimizely.com::asdfsdf-2344-efadf03-343434-efrrr", "variable_definitions": { "advanced": { "default_value": "{\n\t\"hello\": 123\n}", "description": "This variable is used to configure the advanced used for advanced purposes", "key": "advanced", "type": "json" }, "amount": { "default_value": "0.0", "description": "This variable is used to configure the amount used for computing the discount", "key": "amount", "type": "double" }, "message": { "default_value": "Use recurring deposits to compound interest", "description": "This variable is used to configure the message used for displaying the discount", "key": "message", "type": "string" } } }- account_idinteger<int64>DescriptionFormatint64
- archive_urlobject
- UrlValue
- archivedboolean
- created_by_user_emailstringExample
- created_timestring<date-time>requiredExampleFormatdate-time
- delete_urlobject
- UrlValue
- descriptionstringExample
- environmentsmap<string, FlagEnvironment>required
- idintegerrequiredExample
- is_permanentbooleanDescriptionDefaultfalse
- keystringrequiredExample
- namestringrequiredExample
- outlier_filtering_enabledbooleanDefaultfalse
- owner_user_idstringExampleDescription
- project_idinteger<int64>DescriptionFormatint64
- revisionintegerDescription
- rolestringExampleDescription
- team_idsstring[]Example
[ "1234567890", "0987654321" ]
DescriptionDefault - unarchive_urlobject
- UrlValue
- update_urlobject
- UrlValue
- updated_timestring<date-time>requiredExampleFormatdate-time
- urlobjectrequiredDescription
- UrlValue
- urnstringrequiredExampleDescription
- variable_definitionsmap<string, VariableDefinition>Default{}
400
401
403
curl
curl --request POST \
--url https://api.optimizely.com/flags/v1//projects/{project_id}/flags \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"key": "recurring_deposit",
"team_ids": []
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"key": "recurring_deposit",
"team_ids": []
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.optimizely.com/flags/v1//projects/{project_id}/flags", 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")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request.body = JSON.dump({
"key": "recurring_deposit",
"team_ids": []
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.optimizely.com/flags/v1//projects/{project_id}/flags"
payload = json.dumps({
"key": "recurring_deposit",
"team_ids": []
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Successful retrieval, creation or update of a Flag.
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.
{
"account_id": "",
"archive_url": {},
"archived": false,
"created_by_user_email": "[email protected]",
"created_time": "2019-05-08T00:00:00.000Z",
"delete_url": {},
"description": "Flag used for driving customers to use recurring deposits by showing a graph of compound interest over time",
"environments": "",
"id": 45633994,
"is_permanent": false,
"key": "recurring_deposit",
"name": "Recurring Deposit",
"outlier_filtering_enabled": false,
"owner_user_id": "1234-abcd-5678-efgh",
"project_id": "",
"revision": 0,
"role": "admin",
"team_ids": [
""
],
"unarchive_url": {},
"update_url": {},
"updated_time": "2019-05-08T00:00:00.000Z",
"url": {},
"urn": "flags.flag.optimizely.com::asdfsdf-2344-efadf03-343434-efrrr",
"variable_definitions": ""
}400
// Malformed requests and invalid parameter names and types
401
// Invalid credentials
403
// Do not have permission to perform the operation