Skip to main content
POST
/
v1
/
agents
/
{agent_id}
/
scheduled-tasks
Create Scheduled Task
curl --request POST \
  --url https://api.xpander.ai/v1/agents/{agent_id}/scheduled-tasks \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "cron": "<string>",
  "prompt": "<string>",
  "title": "<string>",
  "enabled": true
}
'
import requests

url = "https://api.xpander.ai/v1/agents/{agent_id}/scheduled-tasks"

payload = {
"cron": "<string>",
"prompt": "<string>",
"title": "<string>",
"enabled": True
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({cron: '<string>', prompt: '<string>', title: '<string>', enabled: true})
};

fetch('https://api.xpander.ai/v1/agents/{agent_id}/scheduled-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.xpander.ai/v1/agents/{agent_id}/scheduled-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([
'cron' => '<string>',
'prompt' => '<string>',
'title' => '<string>',
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$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.xpander.ai/v1/agents/{agent_id}/scheduled-tasks"

payload := strings.NewReader("{\n \"cron\": \"<string>\",\n \"prompt\": \"<string>\",\n \"title\": \"<string>\",\n \"enabled\": true\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
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.xpander.ai/v1/agents/{agent_id}/scheduled-tasks")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"cron\": \"<string>\",\n \"prompt\": \"<string>\",\n \"title\": \"<string>\",\n \"enabled\": true\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.xpander.ai/v1/agents/{agent_id}/scheduled-tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cron\": \"<string>\",\n \"prompt\": \"<string>\",\n \"title\": \"<string>\",\n \"enabled\": true\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "cron": "<string>",
  "prompt": "<string>",
  "title": "<string>",
  "enabled": true
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
Create a recurring scheduled task. The change takes effect immediately — the agent runs the given prompt on every cron match.

Request Body

cron
string
required
Cron expression (5-field crontab, UTC). Example: 0 9 * * * runs daily at 09:00 UTC.
prompt
string
required
Instruction the agent runs on each fire.
title
string
Optional human-readable label for the task.
enabled
boolean
default:true
Create the task active (default) or paused.

Example Request

curl -X POST -H "x-api-key: <your-api-key>" -H "Content-Type: application/json" \
  "https://api.xpander.ai/v1/agents/<agent-id>/scheduled-tasks" \
  -d '{
    "cron": "0 9 * * *",
    "prompt": "Summarize yesterday'\''s support tickets and post to #ops.",
    "title": "Daily ticket digest"
  }'

Example Response

{
  "id": "<task-id>",
  "title": "Daily ticket digest",
  "cron": "0 9 * * *",
  "prompt": "Summarize yesterday's support tickets and post to #ops.",
  "enabled": true
}

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

agent_id
string
required

Body

application/json

Create a recurring scheduled task for an agent.

cron
string
required

Cron expression (5-field crontab, UTC), e.g. '0 9 * * *'.

prompt
string
required

Instruction the agent runs on each fire.

title
string | null

Optional human-readable label.

enabled
boolean
default:true

Create the task active (default) or paused.

Response

Successful Response

A recurring scheduled task — the simplified view of one cron task source node.

id
string
required

Source-node id. Pass it to update/remove/run the task.

cron
string
required

Cron expression (5-field crontab, UTC), e.g. '0 9 * * *'.

prompt
string
required

Instruction the agent runs on each fire.

title
string | null

Human-readable label for the task.

enabled
boolean
default:true

Whether the task is active. Disabled tasks keep their config but do not fire.