POST /assets
1 min
POST
https://api.cmp.optimizely.com/v3/assets
Body Parameters
- bodyLibraryAssetCreateRequestrequiredDescription
- keystringrequiredDescriptionMax Length100
- titlestringrequiredExampleDescriptionMin Length1Max Length100
- folder_idstringExampleDescription
Responses
201
- AssetResponse
- idstringrequiredExampleDescription
- titlestringrequiredExampleDescription
- typestring<article | image | video | raw_file | structured_content | compose_content>requiredExampleDescriptionAllowedarticleimagevideoraw_filestructured_contentcompose_content
- mime_typestringrequiredExampleDescription
- file_extensionstringrequiredExampleDescription
- created_atstring<date-time>requiredExampleDescriptionFormatdate-time
- modified_atstring<date-time>requiredExampleDescriptionFormatdate-time
- folder_idstringrequiredExampleDescription
- file_locationstringrequiredExampleDescription
- is_archivedbooleanrequiredDescription
- contentAssetContentrequiredDescription
- typestring<url | api_url | html_body>requiredExampleDescriptionAllowedurlapi_urlhtml_body
- valuestringrequiredExampleDescription
- labelsResourceLabelResponse[]requiredDescription
- groupobjectrequiredDescription
- idstringrequiredExampleDescription
- namestringrequiredExampleDescription
- valuesobject[]requiredDescription
- idstringrequiredExampleDescription
- namestringrequiredExampleDescription
- linksobjectrequiredDescription
- selfstringrequiredExampleDescription
- owner_organization_idstringrequiredExampleDescription
- thumbnail_urlstringrequiredExampleDescription
400
- ErrorExample
{ "message": "Unsupported arguments: a,b,c" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
401
- ErrorExample
{ "message": "Unauthorized" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
403
- ErrorExample
{ "message": "You do not have the permission to perform this operation" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
curl
curl --request POST \
--url https://api.cmp.optimizely.com/v3/assets \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"key": "",
"title": "sample_image.png"
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"key": "",
"title": "sample_image.png"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.cmp.optimizely.com/v3/assets", 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.cmp.optimizely.com/v3/assets")
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": "",
"title": "sample_image.png"
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.cmp.optimizely.com/v3/assets"
payload = json.dumps({
"key": "",
"title": "sample_image.png"
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Created asset
{
"id": "5d7f910551b00a722e0418830cee6631",
"title": "sample_image.png",
"type": "image",
"mime_type": "image/png",
"file_extension": "png",
"created_at": "2019-10-06T13:15:30Z",
"modified_at": "2019-10-07T13:15:30Z",
"folder_id": "6bb8db20a5b611ebae319b7c541b1a5a",
"file_location": "/all assets/important assets",
"is_archived": false,
"content": {
"type": "url",
"value": "http://images.cmp.optimizely.com/Zz0xODQ3NDU3Y2Y2YmYzOTlmNjkyOTgyZDY3Y2I3YWM2OA==S"
},
"labels": [
{
"group": {
"id": "2467e583a60e23fda2b89db81a453cd2",
"name": "Content Format"
},
"values": [
{
"id": "71c378f3fee3d822759d1bdc2aab628c",
"name": "Photos"
}
]
}
],
"links": {
"self": "https://api.cmp.optimizely.com/v3/images/5d7f910551bw0a722e0418830cee6631"
},
"owner_organization_id": "5108c3a9becac35915111191",
"thumbnail_url": "https://images1.cmp.optimizely.com/Pz1kYmI9Z2FkYTJtZWI5VGI1WZq4MTZkNTdmGHjM5OGRmYq=="
}400
// Client error
{
"message": "Not found",
"errors": ""
}401
// Authorization error
{
"message": "Not found",
"errors": ""
}403
// Permission error
{
"message": "Not found",
"errors": ""
}