Create a new task for an agent.
POST
/
tasks
Create Task
curl --request POST \
--url https://api.example.com/tasks \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "<string>",
"agent_name": "<string>",
"branch": "<string>",
"filesystem_id": "<string>",
"name": "<string>",
"params": {},
"project_id": "<string>"
}
'import requests
url = "https://api.example.com/tasks"
payload = {
"agent_id": "<string>",
"agent_name": "<string>",
"branch": "<string>",
"filesystem_id": "<string>",
"name": "<string>",
"params": {},
"project_id": "<string>"
}
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({
agent_id: '<string>',
agent_name: '<string>',
branch: '<string>',
filesystem_id: '<string>',
name: '<string>',
params: {},
project_id: '<string>'
})
};
fetch('https://api.example.com/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_URL => "https://api.example.com/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([
'agent_id' => '<string>',
'agent_name' => '<string>',
'branch' => '<string>',
'filesystem_id' => '<string>',
'name' => '<string>',
'params' => [
],
'project_id' => '<string>'
]),
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 := "https://api.example.com/tasks"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"agent_name\": \"<string>\",\n \"branch\": \"<string>\",\n \"filesystem_id\": \"<string>\",\n \"name\": \"<string>\",\n \"params\": {},\n \"project_id\": \"<string>\"\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("https://api.example.com/tasks")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"<string>\",\n \"agent_name\": \"<string>\",\n \"branch\": \"<string>\",\n \"filesystem_id\": \"<string>\",\n \"name\": \"<string>\",\n \"params\": {},\n \"project_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/tasks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_id\": \"<string>\",\n \"agent_name\": \"<string>\",\n \"branch\": \"<string>\",\n \"filesystem_id\": \"<string>\",\n \"name\": \"<string>\",\n \"params\": {},\n \"project_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"filesystem_id": "<string>",
"id": "<string>",
"namespace_id": "<string>",
"agents": [
{
"created_at": "2023-11-07T05:31:56Z",
"description": "<string>",
"id": "<string>",
"name": "<string>",
"namespace_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"registered_at": "2023-11-07T05:31:56Z",
"registration_metadata": {},
"status": "ACTIVE",
"status_reason": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"created_version_id": "<string>",
"current_version_id": "<string>",
"name": "<string>",
"params": {},
"status_reason": "<string>",
"task_metadata": {},
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}To send messages to a running task, use
sendEvent() after creation. The create() method initializes the task but does not accept message content directly.Body
application/json
Request for POST /tasks
Agent ID (provide this OR agent_name)
Agent name as 'namespace/name' (provide this OR agent_id)
Target branch for version routing
Existing filesystem ID
Task name
Task parameters
Project ID for new filesystem
Response
Successful Response
Task response model with optional related data based on relationships
Show child attributes
Show child attributes
Available options:
IDLE, CANCELED, COMPLETED, FAILED, RUNNING, TERMINATED, TIMED_OUT, DELETED Was this page helpful?
⌘I
Create Task
curl --request POST \
--url https://api.example.com/tasks \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "<string>",
"agent_name": "<string>",
"branch": "<string>",
"filesystem_id": "<string>",
"name": "<string>",
"params": {},
"project_id": "<string>"
}
'import requests
url = "https://api.example.com/tasks"
payload = {
"agent_id": "<string>",
"agent_name": "<string>",
"branch": "<string>",
"filesystem_id": "<string>",
"name": "<string>",
"params": {},
"project_id": "<string>"
}
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({
agent_id: '<string>',
agent_name: '<string>',
branch: '<string>',
filesystem_id: '<string>',
name: '<string>',
params: {},
project_id: '<string>'
})
};
fetch('https://api.example.com/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_URL => "https://api.example.com/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([
'agent_id' => '<string>',
'agent_name' => '<string>',
'branch' => '<string>',
'filesystem_id' => '<string>',
'name' => '<string>',
'params' => [
],
'project_id' => '<string>'
]),
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 := "https://api.example.com/tasks"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"agent_name\": \"<string>\",\n \"branch\": \"<string>\",\n \"filesystem_id\": \"<string>\",\n \"name\": \"<string>\",\n \"params\": {},\n \"project_id\": \"<string>\"\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("https://api.example.com/tasks")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"<string>\",\n \"agent_name\": \"<string>\",\n \"branch\": \"<string>\",\n \"filesystem_id\": \"<string>\",\n \"name\": \"<string>\",\n \"params\": {},\n \"project_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/tasks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_id\": \"<string>\",\n \"agent_name\": \"<string>\",\n \"branch\": \"<string>\",\n \"filesystem_id\": \"<string>\",\n \"name\": \"<string>\",\n \"params\": {},\n \"project_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"filesystem_id": "<string>",
"id": "<string>",
"namespace_id": "<string>",
"agents": [
{
"created_at": "2023-11-07T05:31:56Z",
"description": "<string>",
"id": "<string>",
"name": "<string>",
"namespace_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"registered_at": "2023-11-07T05:31:56Z",
"registration_metadata": {},
"status": "ACTIVE",
"status_reason": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"created_version_id": "<string>",
"current_version_id": "<string>",
"name": "<string>",
"params": {},
"status_reason": "<string>",
"task_metadata": {},
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}