POST /events
1 min
POST
https://api.cmp.optimizely.com/v3/events
Body Parameters
- bodyEventCreateRequestrequiredDescription
- titlestringrequiredExampleDescription
- descriptionstringExampleDescription
- campaign_idstringExampleDescription
- is_all_daybooleanrequiredDescription
- start_datestring<date-time>requiredExampleDescriptionFormatdate-time
- end_datestring<date-time>requiredExampleDescriptionFormatdate-time
- fieldsAssetTypeObjectField[]Description
- BaseObjectField
- typestringrequiredExampleDescription
- valuesundefined[]requiredDescription
- idstringrequiredExampleDescription
- AssetTypeObjectFieldUpdatePayload
- typestringrequiredExampleDescription
- valuesundefined[]requiredDescription
Responses
201
- EventResponse
- idstringrequiredExampleDescription
- titlestringrequiredExampleDescription
- descriptionstringrequiredExampleDescription
- campaign_idstringrequiredExampleDescription
- start_datestringrequiredExampleDescription
- end_datestringrequiredExampleDescription
- is_all_daybooleanrequiredDescription
- is_archivedbooleanrequiredDescription
- created_bystringrequiredExampleDescription
- reference_idstringrequiredExampleDescription
- linksobjectrequiredDescription
- selfstringrequiredExampleDescription
- campaignstringrequiredExampleDescription
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/events \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"title": "The awesome event",
"is_all_day": false,
"start_date": "1996-09-09T12:18:00Z",
"end_date": "2024-12-24T12:18:00Z",
"fields": {
"type": "checkbox",
"values": [],
"id": "41aac313bda1e40b6cde7116fc24a"
}
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"title": "The awesome event",
"is_all_day": false,
"start_date": "1996-09-09T12:18:00Z",
"end_date": "2024-12-24T12:18:00Z",
"fields": {
"type": "checkbox",
"values": [],
"id": "41aac313bda1e40b6cde7116fc24a"
}
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.cmp.optimizely.com/v3/events", 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/events")
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": "The awesome event",
"is_all_day": false,
"start_date": "1996-09-09T12:18:00Z",
"end_date": "2024-12-24T12:18:00Z",
"fields": {
"type": "checkbox",
"values": [],
"id": "41aac313bda1e40b6cde7116fc24a"
}
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.cmp.optimizely.com/v3/events"
payload = json.dumps({
"title": "The awesome event",
"is_all_day": False,
"start_date": "1996-09-09T12:18:00Z",
"end_date": "2024-12-24T12:18:00Z",
"fields": {
"type": "checkbox",
"values": [],
"id": "41aac313bda1e40b6cde7116fc24a"
}
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Created event details
{
"id": "674ea40a7a9cac80ff78c95c",
"title": "The awesome event",
"description": "The awesome event's description",
"campaign_id": "66d953340019d7b86833ac6dg",
"start_date": "2024-11-26T11:00:34Z",
"end_date": "2024-11-26T11:30:34Z",
"is_all_day": false,
"is_archived": false,
"created_by": "66d837c62373533177b59db3",
"reference_id": "EVT-3",
"links": {
"self": "https://api.cmp.optimizely.com/v3/events/674ea40a7a9cac80ff78c95c",
"campaign": "https://api.cmp.optimizely.com/v3/campaigns/66d953340019d7b86833ac6d"
}
}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": ""
}