POST /campaigns
1 min
POST
https://api.cmp.optimizely.com/v3/campaigns
Body Parameters
- bodyCampaignCreateRequestrequiredDescription
- titlestringrequiredExampleDescription
- descriptionstringExampleDescription
- parent_campaignstringExampleDescription
- start_datestring<date>ExampleDescriptionFormatdate
- end_datestring<date>ExampleDescriptionFormatdate
- owner_idstringExampleDescription
- colorstring<#333 | #ec2e3b | #fc594b | #e2575b | #f45097 | #de55a9 | #bd417f | #a959cc | #6456b7 | #4db2fc | #3a97be | #36c5a3 | #9bc94e | #fdad3c | #ef803c | #fd8876 | #ea868a | #f781b5 | #e785c1 | #cf69a3 | #c187db | #9086cc | #79c8fd | #5ab5d0 | #4fd5bd | #b8d877 | #fec454 | #f3a35a | #d3998f | #c79697 | #d096af | #c897b4 | #ae7c98 | #b094be | #908bae | #97bed8 | #7aa8b6 | #7abeb2 | #bece9d | #e3c68d | #d3ac85 | #b9a29e | #b29f9f | #b9a1ac | #b5a1ae | #9a8692 | #a89bac | #908e9b | #a8b9c3 | #8ea1a7 | #96b1ac | #c1c8b5 | #d4c8b0 | #c0b0a1 | #212121 | #CE515B | #F16281 | #EB7777 | #A25555 | #B05F8C | #AF8EC3 | #21B7EC | #3AB0C9 | #669BA8 | #7ABEB2 | #5F9DCE | #717CB9 | #4C557E | #449C6C | #63B05F | #4D9B93 | #ACC050 | #A29F55 | #8AA872 | #E4844C | #EE9808 | #DE7009 | #FCD404 | #CBB039 | #99896A | #2e2a26 | #ccccdc>ExampleDescriptionAllowed#333#ec2e3b#fc594b#e2575b#f45097#de55a9#bd417f#a959cc#6456b7#4db2fc#3a97be#36c5a3#9bc94e#fdad3c#ef803c#fd8876#ea868a#f781b5#e785c1#cf69a3#c187db#9086cc#79c8fd#5ab5d0#4fd5bd#b8d877#fec454#f3a35a#d3998f#c79697#d096af#c897b4#ae7c98#b094be#908bae#97bed8#7aa8b6#7abeb2#bece9d#e3c68d#d3ac85#b9a29e#b29f9f#b9a1ac#b5a1ae#9a8692#a89bac#908e9b#a8b9c3#8ea1a7#96b1ac#c1c8b5#d4c8b0#c0b0a1#212121#CE515B#F16281#EB7777#A25555#B05F8C#AF8EC3#21B7EC#3AB0C9#669BA8#7ABEB2#5F9DCE#717CB9#4C557E#449C6C#63B05F#4D9B93#ACC050#A29F55#8AA872#E4844C#EE9808#DE7009#FCD404#CBB039#99896A#2e2a26#ccccdc
Responses
201
- CampaignResponse
- idstringrequiredExampleDescription
- titlestringrequiredExampleDescription
- descriptionstringrequiredExampleDescription
- start_datestringrequiredExampleDescription
- end_datestringrequiredExampleDescription
- created_atstring<date-time>requiredExampleDescriptionFormatdate-time
- is_hiddenbooleanrequiredDescription
- statusstring<Not Started | Off Track | On Track | Complete | At Risk>requiredExampleDescriptionAllowedNot StartedOff TrackOn TrackCompleteAt Risk
- reference_idstringrequiredExampleDescription
- budgetobjectrequired
- BudgetResponse
- currency_codestringrequiredExampleDescription
- budgeted_amountstringrequiredExampleDescription
- labelsResourceLabelResponse[]requiredDescription
- groupobjectrequiredDescription
- idstringrequiredExampleDescription
- namestringrequiredExampleDescription
- valuesobject[]requiredDescription
- idstringrequiredExampleDescription
- namestringrequiredExampleDescription
- linksobjectrequiredDescription
- selfstringrequiredExampleDescription
- briefstringrequiredExampleDescription
- ownerstringrequiredExampleDescription
- parent_campaignstringrequiredExampleDescription
- child_campaignsstring[]requiredExample
[ "https://api.cmp.optimizely.com/v3/campaigns/6fb21acf987094513ecb4b58" ]
Description
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
404
- ErrorExample
{ "message": "Resource not found" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
422
- ErrorExample
{ "message": "Resource cannot be processed" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
curl
curl --request POST \
--url https://api.cmp.optimizely.com/v3/campaigns \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"title": "Sample Title"
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"title": "Sample Title"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.cmp.optimizely.com/v3/campaigns", 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/campaigns")
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({
"title": "Sample Title"
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.cmp.optimizely.com/v3/campaigns"
payload = json.dumps({
"title": "Sample Title"
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Created campaign
{
"id": "8q7f910551b00a722e0418830cee6612",
"title": "The awesome campaign",
"description": "The awesome campaign's description",
"start_date": "2019-10-06",
"end_date": "2019-10-16",
"created_at": "2035-10-06T13:15:30Z",
"is_hidden": false,
"status": "On Track",
"reference_id": "CPN-1589",
"budget": {},
"labels": [
{
"group": {
"id": "2467e583a60e23fda2b89db81a453cd2",
"name": "Content Format"
},
"values": [
{
"id": "71c378f3fee3d822759d1bdc2aab628c",
"name": "Photos"
}
]
}
],
"links": {
"self": "https://api.cmp.optimizely.com/v3/campaigns/8q7f910551b00a722e0418830cee6612",
"brief": "https://api.cmp.optimizely.com/v3/campaigns/8q7f910551b00a722e0418830cee6612/brief",
"owner": "https://api.cmp.optimizely.com/v3/users/6ea1bf781398c3147393arr1",
"parent_campaign": "https://api.cmp.optimizely.com/v3/campaigns/7u7f910551b00a722e0418830cee6643",
"child_campaigns": [
"https://api.cmp.optimizely.com/v3/campaigns/6fb21acf987094513ecb4b58"
]
}
}400
// Client error
{
"message": "Not found",
"errors": ""
}401
// Authorization error
{
"message": "Not found",
"errors": ""
}403
// Permission error
{
"message": "Not found",
"errors": ""
}404
// Not found error
{
"message": "Not found",
"errors": ""
}422
// Unprocessable entity error
{
"message": "Not found",
"errors": ""
}