Create an Attribute
1 min
POST
https://api.optimizely.com/v2/attributes
Body Parameters
- bodyAttributerequiredDescription
- archivedbooleanDescriptionDefaultfalse
- descriptionstringDescription
- keystringrequiredExampleDescriptionMax Length64Pattern^[a-zA-Z0-9_\- .]+$
- namestringExampleDescription
- project_idinteger<int64>requiredExampleDescriptionFormatint64
Responses
201
- Attribute
- archivedbooleanDescriptionDefaultfalse
- condition_typestring<custom_attribute | custom_dimension>DescriptionDefaultcustom_attributeAllowedcustom_attributecustom_dimension
- descriptionstringDescription
- idinteger<int64>DescriptionFormatint64
- keystringrequiredExampleDescriptionMax Length64Pattern^[a-zA-Z0-9_\- .]+$
- last_modifiedstring<date-time>DescriptionFormatdate-time
- namestringExampleDescription
- project_idinteger<int64>requiredExampleDescriptionFormatint64
400
- Error
- codestring
- messagestring
- messagesobject
- uuidstring<uuid>Formatuuid
401
- 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/attributes \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"key": "subscriber_status",
"project_id": 17738411154
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"key": "subscriber_status",
"project_id": 17738411154
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.optimizely.com/v2/attributes", 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/attributes")
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": "subscriber_status",
"project_id": 17738411154
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.optimizely.com/v2/attributes"
payload = json.dumps({
"key": "subscriber_status",
"project_id": 17738411154
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Successfully created the Attribute
{
"archived": false,
"condition_type": "",
"description": "",
"id": "",
"key": "subscriber_status",
"last_modified": "",
"name": "Subscriber Status",
"project_id": 17738411154
}400
// Invalid request body content
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}401
// Invalid credentials
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}default
// Unexpected error
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}