Create a background task
POST
/
background
/
tasks
Create a background task
curl --request POST \
--url http://localhost:8000/background/tasks \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"schedule": {
"end_at": "2023-11-07T05:31:56Z",
"expression": "<string>",
"jitter_seconds": 123,
"misfire_policy": "skip_missed",
"run_at": "2023-11-07T05:31:56Z",
"seconds": 123,
"start_at": "2023-11-07T05:31:56Z",
"timezone": "UTC"
},
"task_id": "<string>",
"agent_id": "<string>",
"enabled": true,
"metadata": {},
"overlap_policy": "skip_if_running",
"replace": false,
"retry_policy": {
"backoff": "fixed",
"initial_delay_seconds": 30,
"max_delay_seconds": 300,
"max_retries": 0,
"retry_on": [
"<string>"
]
},
"session_policy": {
"mode": "task",
"session_id": "<string>"
},
"timeout_seconds": 123,
"workspace_policy": {
"namespace_template": "background/{agent_id}/{task_id}/{run_id}",
"write_events_jsonl": true,
"write_run_json": true
}
}
'import requests
url = "http://localhost:8000/background/tasks"
payload = {
"query": "<string>",
"schedule": {
"end_at": "2023-11-07T05:31:56Z",
"expression": "<string>",
"jitter_seconds": 123,
"misfire_policy": "skip_missed",
"run_at": "2023-11-07T05:31:56Z",
"seconds": 123,
"start_at": "2023-11-07T05:31:56Z",
"timezone": "UTC"
},
"task_id": "<string>",
"agent_id": "<string>",
"enabled": True,
"metadata": {},
"overlap_policy": "skip_if_running",
"replace": False,
"retry_policy": {
"backoff": "fixed",
"initial_delay_seconds": 30,
"max_delay_seconds": 300,
"max_retries": 0,
"retry_on": ["<string>"]
},
"session_policy": {
"mode": "task",
"session_id": "<string>"
},
"timeout_seconds": 123,
"workspace_policy": {
"namespace_template": "background/{agent_id}/{task_id}/{run_id}",
"write_events_jsonl": True,
"write_run_json": True
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
schedule: {
end_at: '2023-11-07T05:31:56Z',
expression: '<string>',
jitter_seconds: 123,
misfire_policy: 'skip_missed',
run_at: '2023-11-07T05:31:56Z',
seconds: 123,
start_at: '2023-11-07T05:31:56Z',
timezone: 'UTC'
},
task_id: '<string>',
agent_id: '<string>',
enabled: true,
metadata: {},
overlap_policy: 'skip_if_running',
replace: false,
retry_policy: {
backoff: 'fixed',
initial_delay_seconds: 30,
max_delay_seconds: 300,
max_retries: 0,
retry_on: ['<string>']
},
session_policy: {mode: 'task', session_id: '<string>'},
timeout_seconds: 123,
workspace_policy: {
namespace_template: 'background/{agent_id}/{task_id}/{run_id}',
write_events_jsonl: true,
write_run_json: true
}
})
};
fetch('http://localhost:8000/background/tasks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8000",
CURLOPT_URL => "http://localhost:8000/background/tasks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'schedule' => [
'end_at' => '2023-11-07T05:31:56Z',
'expression' => '<string>',
'jitter_seconds' => 123,
'misfire_policy' => 'skip_missed',
'run_at' => '2023-11-07T05:31:56Z',
'seconds' => 123,
'start_at' => '2023-11-07T05:31:56Z',
'timezone' => 'UTC'
],
'task_id' => '<string>',
'agent_id' => '<string>',
'enabled' => true,
'metadata' => [
],
'overlap_policy' => 'skip_if_running',
'replace' => false,
'retry_policy' => [
'backoff' => 'fixed',
'initial_delay_seconds' => 30,
'max_delay_seconds' => 300,
'max_retries' => 0,
'retry_on' => [
'<string>'
]
],
'session_policy' => [
'mode' => 'task',
'session_id' => '<string>'
],
'timeout_seconds' => 123,
'workspace_policy' => [
'namespace_template' => 'background/{agent_id}/{task_id}/{run_id}',
'write_events_jsonl' => true,
'write_run_json' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8000/background/tasks"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"schedule\": {\n \"end_at\": \"2023-11-07T05:31:56Z\",\n \"expression\": \"<string>\",\n \"jitter_seconds\": 123,\n \"misfire_policy\": \"skip_missed\",\n \"run_at\": \"2023-11-07T05:31:56Z\",\n \"seconds\": 123,\n \"start_at\": \"2023-11-07T05:31:56Z\",\n \"timezone\": \"UTC\"\n },\n \"task_id\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true,\n \"metadata\": {},\n \"overlap_policy\": \"skip_if_running\",\n \"replace\": false,\n \"retry_policy\": {\n \"backoff\": \"fixed\",\n \"initial_delay_seconds\": 30,\n \"max_delay_seconds\": 300,\n \"max_retries\": 0,\n \"retry_on\": [\n \"<string>\"\n ]\n },\n \"session_policy\": {\n \"mode\": \"task\",\n \"session_id\": \"<string>\"\n },\n \"timeout_seconds\": 123,\n \"workspace_policy\": {\n \"namespace_template\": \"background/{agent_id}/{task_id}/{run_id}\",\n \"write_events_jsonl\": true,\n \"write_run_json\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8000/background/tasks")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"schedule\": {\n \"end_at\": \"2023-11-07T05:31:56Z\",\n \"expression\": \"<string>\",\n \"jitter_seconds\": 123,\n \"misfire_policy\": \"skip_missed\",\n \"run_at\": \"2023-11-07T05:31:56Z\",\n \"seconds\": 123,\n \"start_at\": \"2023-11-07T05:31:56Z\",\n \"timezone\": \"UTC\"\n },\n \"task_id\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true,\n \"metadata\": {},\n \"overlap_policy\": \"skip_if_running\",\n \"replace\": false,\n \"retry_policy\": {\n \"backoff\": \"fixed\",\n \"initial_delay_seconds\": 30,\n \"max_delay_seconds\": 300,\n \"max_retries\": 0,\n \"retry_on\": [\n \"<string>\"\n ]\n },\n \"session_policy\": {\n \"mode\": \"task\",\n \"session_id\": \"<string>\"\n },\n \"timeout_seconds\": 123,\n \"workspace_policy\": {\n \"namespace_template\": \"background/{agent_id}/{task_id}/{run_id}\",\n \"write_events_jsonl\": true,\n \"write_run_json\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8000/background/tasks")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"schedule\": {\n \"end_at\": \"2023-11-07T05:31:56Z\",\n \"expression\": \"<string>\",\n \"jitter_seconds\": 123,\n \"misfire_policy\": \"skip_missed\",\n \"run_at\": \"2023-11-07T05:31:56Z\",\n \"seconds\": 123,\n \"start_at\": \"2023-11-07T05:31:56Z\",\n \"timezone\": \"UTC\"\n },\n \"task_id\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true,\n \"metadata\": {},\n \"overlap_policy\": \"skip_if_running\",\n \"replace\": false,\n \"retry_policy\": {\n \"backoff\": \"fixed\",\n \"initial_delay_seconds\": 30,\n \"max_delay_seconds\": 300,\n \"max_retries\": 0,\n \"retry_on\": [\n \"<string>\"\n ]\n },\n \"session_policy\": {\n \"mode\": \"task\",\n \"session_id\": \"<string>\"\n },\n \"timeout_seconds\": 123,\n \"workspace_policy\": {\n \"namespace_template\": \"background/{agent_id}/{task_id}/{run_id}\",\n \"write_events_jsonl\": true,\n \"write_run_json\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"agent_id": "<string>",
"query": "<string>",
"schedule": {
"type": "manual",
"end_at": "2023-11-07T05:31:56Z",
"expression": "<string>",
"jitter_seconds": 123,
"misfire_policy": "skip_missed",
"run_at": "2023-11-07T05:31:56Z",
"seconds": 123,
"start_at": "2023-11-07T05:31:56Z",
"timezone": "UTC"
},
"task_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"enabled": true,
"metadata": {},
"overlap_policy": "skip_if_running",
"retry_policy": {
"backoff": "fixed",
"initial_delay_seconds": 30,
"max_delay_seconds": 300,
"max_retries": 0,
"retry_on": [
"<string>"
]
},
"session_policy": {
"mode": "task",
"session_id": "<string>"
},
"timeout_seconds": 123,
"updated_at": "2023-11-07T05:31:56Z",
"workspace_policy": {
"namespace_template": "background/{agent_id}/{task_id}/{run_id}",
"write_events_jsonl": true,
"write_run_json": true
}
}{
"detail": "<unknown>"
}{
"detail": "<unknown>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"ctx": {},
"input": "<unknown>"
}
]
}{
"detail": "<unknown>"
}Body
application/json
Create a background task.
Instruction executed for each run
Manual, once, interval, or cron
Show child attributes
Show child attributes
Stable task identifier
Agent id. Defaults to OmniServe background_agent_id.
Whether the scheduler may run it
Available options:
skip_if_running, queue_next, cancel_previous, allow_parallel Replace an existing task
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Per-run timeout
Show child attributes
Show child attributes
Response
Successful Response
Show child attributes
Show child attributes
Available options:
skip_if_running, queue_next, cancel_previous, allow_parallel Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
⌘I
Create a background task
curl --request POST \
--url http://localhost:8000/background/tasks \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"schedule": {
"end_at": "2023-11-07T05:31:56Z",
"expression": "<string>",
"jitter_seconds": 123,
"misfire_policy": "skip_missed",
"run_at": "2023-11-07T05:31:56Z",
"seconds": 123,
"start_at": "2023-11-07T05:31:56Z",
"timezone": "UTC"
},
"task_id": "<string>",
"agent_id": "<string>",
"enabled": true,
"metadata": {},
"overlap_policy": "skip_if_running",
"replace": false,
"retry_policy": {
"backoff": "fixed",
"initial_delay_seconds": 30,
"max_delay_seconds": 300,
"max_retries": 0,
"retry_on": [
"<string>"
]
},
"session_policy": {
"mode": "task",
"session_id": "<string>"
},
"timeout_seconds": 123,
"workspace_policy": {
"namespace_template": "background/{agent_id}/{task_id}/{run_id}",
"write_events_jsonl": true,
"write_run_json": true
}
}
'import requests
url = "http://localhost:8000/background/tasks"
payload = {
"query": "<string>",
"schedule": {
"end_at": "2023-11-07T05:31:56Z",
"expression": "<string>",
"jitter_seconds": 123,
"misfire_policy": "skip_missed",
"run_at": "2023-11-07T05:31:56Z",
"seconds": 123,
"start_at": "2023-11-07T05:31:56Z",
"timezone": "UTC"
},
"task_id": "<string>",
"agent_id": "<string>",
"enabled": True,
"metadata": {},
"overlap_policy": "skip_if_running",
"replace": False,
"retry_policy": {
"backoff": "fixed",
"initial_delay_seconds": 30,
"max_delay_seconds": 300,
"max_retries": 0,
"retry_on": ["<string>"]
},
"session_policy": {
"mode": "task",
"session_id": "<string>"
},
"timeout_seconds": 123,
"workspace_policy": {
"namespace_template": "background/{agent_id}/{task_id}/{run_id}",
"write_events_jsonl": True,
"write_run_json": True
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
schedule: {
end_at: '2023-11-07T05:31:56Z',
expression: '<string>',
jitter_seconds: 123,
misfire_policy: 'skip_missed',
run_at: '2023-11-07T05:31:56Z',
seconds: 123,
start_at: '2023-11-07T05:31:56Z',
timezone: 'UTC'
},
task_id: '<string>',
agent_id: '<string>',
enabled: true,
metadata: {},
overlap_policy: 'skip_if_running',
replace: false,
retry_policy: {
backoff: 'fixed',
initial_delay_seconds: 30,
max_delay_seconds: 300,
max_retries: 0,
retry_on: ['<string>']
},
session_policy: {mode: 'task', session_id: '<string>'},
timeout_seconds: 123,
workspace_policy: {
namespace_template: 'background/{agent_id}/{task_id}/{run_id}',
write_events_jsonl: true,
write_run_json: true
}
})
};
fetch('http://localhost:8000/background/tasks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8000",
CURLOPT_URL => "http://localhost:8000/background/tasks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'schedule' => [
'end_at' => '2023-11-07T05:31:56Z',
'expression' => '<string>',
'jitter_seconds' => 123,
'misfire_policy' => 'skip_missed',
'run_at' => '2023-11-07T05:31:56Z',
'seconds' => 123,
'start_at' => '2023-11-07T05:31:56Z',
'timezone' => 'UTC'
],
'task_id' => '<string>',
'agent_id' => '<string>',
'enabled' => true,
'metadata' => [
],
'overlap_policy' => 'skip_if_running',
'replace' => false,
'retry_policy' => [
'backoff' => 'fixed',
'initial_delay_seconds' => 30,
'max_delay_seconds' => 300,
'max_retries' => 0,
'retry_on' => [
'<string>'
]
],
'session_policy' => [
'mode' => 'task',
'session_id' => '<string>'
],
'timeout_seconds' => 123,
'workspace_policy' => [
'namespace_template' => 'background/{agent_id}/{task_id}/{run_id}',
'write_events_jsonl' => true,
'write_run_json' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8000/background/tasks"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"schedule\": {\n \"end_at\": \"2023-11-07T05:31:56Z\",\n \"expression\": \"<string>\",\n \"jitter_seconds\": 123,\n \"misfire_policy\": \"skip_missed\",\n \"run_at\": \"2023-11-07T05:31:56Z\",\n \"seconds\": 123,\n \"start_at\": \"2023-11-07T05:31:56Z\",\n \"timezone\": \"UTC\"\n },\n \"task_id\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true,\n \"metadata\": {},\n \"overlap_policy\": \"skip_if_running\",\n \"replace\": false,\n \"retry_policy\": {\n \"backoff\": \"fixed\",\n \"initial_delay_seconds\": 30,\n \"max_delay_seconds\": 300,\n \"max_retries\": 0,\n \"retry_on\": [\n \"<string>\"\n ]\n },\n \"session_policy\": {\n \"mode\": \"task\",\n \"session_id\": \"<string>\"\n },\n \"timeout_seconds\": 123,\n \"workspace_policy\": {\n \"namespace_template\": \"background/{agent_id}/{task_id}/{run_id}\",\n \"write_events_jsonl\": true,\n \"write_run_json\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8000/background/tasks")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"schedule\": {\n \"end_at\": \"2023-11-07T05:31:56Z\",\n \"expression\": \"<string>\",\n \"jitter_seconds\": 123,\n \"misfire_policy\": \"skip_missed\",\n \"run_at\": \"2023-11-07T05:31:56Z\",\n \"seconds\": 123,\n \"start_at\": \"2023-11-07T05:31:56Z\",\n \"timezone\": \"UTC\"\n },\n \"task_id\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true,\n \"metadata\": {},\n \"overlap_policy\": \"skip_if_running\",\n \"replace\": false,\n \"retry_policy\": {\n \"backoff\": \"fixed\",\n \"initial_delay_seconds\": 30,\n \"max_delay_seconds\": 300,\n \"max_retries\": 0,\n \"retry_on\": [\n \"<string>\"\n ]\n },\n \"session_policy\": {\n \"mode\": \"task\",\n \"session_id\": \"<string>\"\n },\n \"timeout_seconds\": 123,\n \"workspace_policy\": {\n \"namespace_template\": \"background/{agent_id}/{task_id}/{run_id}\",\n \"write_events_jsonl\": true,\n \"write_run_json\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8000/background/tasks")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"schedule\": {\n \"end_at\": \"2023-11-07T05:31:56Z\",\n \"expression\": \"<string>\",\n \"jitter_seconds\": 123,\n \"misfire_policy\": \"skip_missed\",\n \"run_at\": \"2023-11-07T05:31:56Z\",\n \"seconds\": 123,\n \"start_at\": \"2023-11-07T05:31:56Z\",\n \"timezone\": \"UTC\"\n },\n \"task_id\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true,\n \"metadata\": {},\n \"overlap_policy\": \"skip_if_running\",\n \"replace\": false,\n \"retry_policy\": {\n \"backoff\": \"fixed\",\n \"initial_delay_seconds\": 30,\n \"max_delay_seconds\": 300,\n \"max_retries\": 0,\n \"retry_on\": [\n \"<string>\"\n ]\n },\n \"session_policy\": {\n \"mode\": \"task\",\n \"session_id\": \"<string>\"\n },\n \"timeout_seconds\": 123,\n \"workspace_policy\": {\n \"namespace_template\": \"background/{agent_id}/{task_id}/{run_id}\",\n \"write_events_jsonl\": true,\n \"write_run_json\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"agent_id": "<string>",
"query": "<string>",
"schedule": {
"type": "manual",
"end_at": "2023-11-07T05:31:56Z",
"expression": "<string>",
"jitter_seconds": 123,
"misfire_policy": "skip_missed",
"run_at": "2023-11-07T05:31:56Z",
"seconds": 123,
"start_at": "2023-11-07T05:31:56Z",
"timezone": "UTC"
},
"task_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"enabled": true,
"metadata": {},
"overlap_policy": "skip_if_running",
"retry_policy": {
"backoff": "fixed",
"initial_delay_seconds": 30,
"max_delay_seconds": 300,
"max_retries": 0,
"retry_on": [
"<string>"
]
},
"session_policy": {
"mode": "task",
"session_id": "<string>"
},
"timeout_seconds": 123,
"updated_at": "2023-11-07T05:31:56Z",
"workspace_policy": {
"namespace_template": "background/{agent_id}/{task_id}/{run_id}",
"write_events_jsonl": true,
"write_run_json": true
}
}{
"detail": "<unknown>"
}{
"detail": "<unknown>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"ctx": {},
"input": "<unknown>"
}
]
}{
"detail": "<unknown>"
}