Create an Extension
1 min
POST
https://api.optimizely.com/v2/extensions
Body Parameters
- bodyExtensionrequiredDescription
- descriptionstringDescription
- edit_urlstringrequiredDescription
- enabledbooleanDescription
- fieldsField[]Description
- api_namestringrequiredDescription
- default_valuestringrequiredDescription
- field_typestring<selector | text | multi_text | rich_text | number | html | css | js | toggle | dropdown | multi_select | image | color | slider>requiredDescriptionAllowedselectortextmulti_textrich_textnumberhtmlcssjstoggledropdownmulti_selectimagecolorslider
- labelstringrequiredDescription
- optionsOptions
- choicesChoices[]Description
- labelstringDescription
- valuestringDescription
- implementationImplementationrequired
- apply_jsstringDescriptionDefault
- cssstringDescriptionDefault
- htmlstringDescriptionDefault
- reset_jsstringDescriptionDefault
- namestringrequiredExampleDescription
- project_idinteger<int64>requiredExampleDescriptionFormatint64
Responses
201
- Extension
- archivedbooleanDescription
- createdstring<date-time>DescriptionFormatdate-time
- descriptionstringDescription
- edit_urlstringrequiredDescription
- enabledbooleanDescription
- experiment_countinteger<int64>ExampleDescriptionFormatint64
- fieldsField[]Description
- api_namestringrequiredDescription
- default_valuestringrequiredDescription
- field_typestring<selector | text | multi_text | rich_text | number | html | css | js | toggle | dropdown | multi_select | image | color | slider>requiredDescriptionAllowedselectortextmulti_textrich_textnumberhtmlcssjstoggledropdownmulti_selectimagecolorslider
- labelstringrequiredDescription
- optionsOptions
- choicesChoices[]Description
- labelstringDescription
- valuestringDescription
- idinteger<int64>ExampleDescriptionFormatint64
- implementationImplementationrequired
- apply_jsstringDescriptionDefault
- cssstringDescriptionDefault
- htmlstringDescriptionDefault
- reset_jsstringDescriptionDefault
- last_modifiedstring<date-time>DescriptionFormatdate-time
- namestringrequiredExampleDescription
- project_idinteger<int64>requiredExampleDescriptionFormatint64
400
- Error
- codestring
- messagestring
- messagesobject
- uuidstring<uuid>Formatuuid
401
- Error
- codestring
- messagestring
- messagesobject
- uuidstring<uuid>Formatuuid
403
- Error
- codestring
- messagestring
- messagesobject
- uuidstring<uuid>Formatuuid
default
- Error
- codestring
- messagestring
- messagesobject
- uuidstring<uuid>Formatuuid
curl
curl --request POST \
--url https://api.optimizely.com/v2/extensions \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"edit_url": "",
"fields": [
{
"api_name": "",
"default_value": "",
"field_type": "",
"label": ""
}
],
"implementation": {},
"name": "My Extension",
"project_id": 1000
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"edit_url": "",
"fields": [
{
"api_name": "",
"default_value": "",
"field_type": "",
"label": ""
}
],
"implementation": {},
"name": "My Extension",
"project_id": 1000
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.optimizely.com/v2/extensions", 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/v2/extensions")
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({
"edit_url": "",
"fields": [
{
"api_name": "",
"default_value": "",
"field_type": "",
"label": ""
}
],
"implementation": {},
"name": "My Extension",
"project_id": 1000
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.optimizely.com/v2/extensions"
payload = json.dumps({
"edit_url": "",
"fields": [
{
"api_name": "",
"default_value": "",
"field_type": "",
"label": ""
}
],
"implementation": {},
"name": "My Extension",
"project_id": 1000
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Return the created extension
{
"archived": false,
"created": "",
"description": "",
"edit_url": "",
"enabled": false,
"experiment_count": 3,
"fields": [
{
"api_name": "",
"default_value": "",
"field_type": "",
"label": "",
"options": {
"choices": [
{
"label": "",
"value": ""
}
]
}
}
],
"id": 3000,
"implementation": {
"apply_js": "",
"css": "",
"html": "",
"reset_js": ""
},
"last_modified": "",
"name": "My Extension",
"project_id": 1000
}400
// Invalid request body content
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}401
// Invalid credentials
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}403
// You do not have permission to create an extension under the specified project
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}default
// Unexpected error
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}