Create a Scheduled Job
1 min
POST
https://api.optimizely.com/v2/scheduled-jobs
Body Parameters
- bodyScheduledJobrequiredDescription
- campaign_idsinteger[]Example
[ 12, 34 ]
DescriptionDefault - experiment_idsinteger[]Example
[ 56, 78, 90 ]
DescriptionDefault - frequencystring<daily | weekly>requiredExampleDescriptionAlloweddailyweekly
- job_typestring<project_results>requiredExampleDescriptionAllowedproject_results
- output_channelsobjectExample
{ "email": [ "[email protected]", "[email protected]" ] }DescriptionDefault{} - project_idinteger<int64>requiredExampleDescriptionFormatint64
Responses
201
- ScheduledJob
- account_idinteger<int64>ExampleDescriptionFormatint64
- archivedbooleanDescriptionDefaultfalse
- campaign_idsinteger[]Example
[ 12, 34 ]
DescriptionDefault - experiment_idsinteger[]Example
[ 56, 78, 90 ]
DescriptionDefault - frequencystring<daily | weekly>requiredExampleDescriptionAlloweddailyweekly
- idinteger<int64>ExampleDescriptionFormatint64
- job_typestring<project_results>requiredExampleDescriptionAllowedproject_results
- output_channelsobjectExample
{ "email": [ "[email protected]", "[email protected]" ] }DescriptionDefault{} - 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/scheduled-jobs \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"campaign_ids": [],
"experiment_ids": [],
"frequency": "weekly",
"job_type": "project_results",
"output_channels": {},
"project_id": 789
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"campaign_ids": [],
"experiment_ids": [],
"frequency": "weekly",
"job_type": "project_results",
"output_channels": {},
"project_id": 789
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.optimizely.com/v2/scheduled-jobs", 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/scheduled-jobs")
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({
"campaign_ids": [],
"experiment_ids": [],
"frequency": "weekly",
"job_type": "project_results",
"output_channels": {},
"project_id": 789
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.optimizely.com/v2/scheduled-jobs"
payload = json.dumps({
"campaign_ids": [],
"experiment_ids": [],
"frequency": "weekly",
"job_type": "project_results",
"output_channels": {},
"project_id": 789
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Return the created ScheduledJob
{
"account_id": 456,
"archived": false,
"campaign_ids": [
0
],
"experiment_ids": [
0
],
"frequency": "weekly",
"id": 123,
"job_type": "project_results",
"output_channels": {},
"project_id": 789
}400
// Invalid request body content
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}401
// Invalid credentials
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}403
// You do not have permission to create a Scheduled Job under the specified Project
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}default
// Unexpected error
{
"code": "",
"message": "",
"messages": {},
"uuid": ""
}