curl --request POST "${HARNESS_URL}/harness/cronjobs" \
--header "Authorization: Bearer ${HARNESS_TOKEN}" \
--header "Content-Type: application/json" \
--data '{"name": "daily-report", "prompt": "Summarize recent activity", "schedule": {"cron": "0 9 * * *", "timezone": "Asia/Shanghai"}, "idempotency_key": "daily-report-v1"}'import json
import os
from urllib.request import Request, urlopen
base_url = os.environ["HARNESS_URL"]
headers = {"Authorization": "Bearer " + os.environ["HARNESS_TOKEN"]}
headers["Content-Type"] = "application/json"
data = json.dumps({'name': 'daily-report', 'prompt': 'Summarize recent activity', 'schedule': {'cron': '0 9 * * *', 'timezone': 'Asia/Shanghai'}, 'idempotency_key': 'daily-report-v1'}).encode()
request = Request(base_url + f"/harness/cronjobs", headers=headers, method="POST", data=data)
with urlopen(request) as response:
print(json.load(response))const baseUrl = process.env.HARNESS_URL;
const headers = { Authorization: `Bearer ${process.env.HARNESS_TOKEN}` };
headers["Content-Type"] = "application/json";
const response = await fetch(`${baseUrl}/harness/cronjobs`, {
method: "POST",
headers,
body: JSON.stringify({"name": "daily-report", "prompt": "Summarize recent activity", "schedule": {"cron": "0 9 * * *", "timezone": "Asia/Shanghai"}, "idempotency_key": "daily-report-v1"}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());{
"name": "daily-report",
"prompt": "Summarize recent activity",
"schedule": {
"cron": "0 9 * * *",
"at": null,
"timezone": "Asia/Shanghai"
},
"enabled": true,
"timeout_seconds": 1800,
"misfire_policy": "latest",
"misfire_grace_seconds": 120,
"harness": null,
"cronjob_id": "0e58ff7f7dcbf348c252fc70e7fdb587",
"revision": 1,
"created_at": "2026-09-16T00:00:00Z",
"updated_at": "2026-09-16T00:00:00Z",
"next_run_at": "2026-09-16T01:00:00Z",
"active": null,
"last_run": null
}Create a scheduled task
Create a recurring or one-time task and return its definition and state
curl --request POST "${HARNESS_URL}/harness/cronjobs" \
--header "Authorization: Bearer ${HARNESS_TOKEN}" \
--header "Content-Type: application/json" \
--data '{"name": "daily-report", "prompt": "Summarize recent activity", "schedule": {"cron": "0 9 * * *", "timezone": "Asia/Shanghai"}, "idempotency_key": "daily-report-v1"}'import json
import os
from urllib.request import Request, urlopen
base_url = os.environ["HARNESS_URL"]
headers = {"Authorization": "Bearer " + os.environ["HARNESS_TOKEN"]}
headers["Content-Type"] = "application/json"
data = json.dumps({'name': 'daily-report', 'prompt': 'Summarize recent activity', 'schedule': {'cron': '0 9 * * *', 'timezone': 'Asia/Shanghai'}, 'idempotency_key': 'daily-report-v1'}).encode()
request = Request(base_url + f"/harness/cronjobs", headers=headers, method="POST", data=data)
with urlopen(request) as response:
print(json.load(response))const baseUrl = process.env.HARNESS_URL;
const headers = { Authorization: `Bearer ${process.env.HARNESS_TOKEN}` };
headers["Content-Type"] = "application/json";
const response = await fetch(`${baseUrl}/harness/cronjobs`, {
method: "POST",
headers,
body: JSON.stringify({"name": "daily-report", "prompt": "Summarize recent activity", "schedule": {"cron": "0 9 * * *", "timezone": "Asia/Shanghai"}, "idempotency_key": "daily-report-v1"}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());{
"name": "daily-report",
"prompt": "Summarize recent activity",
"schedule": {
"cron": "0 9 * * *",
"at": null,
"timezone": "Asia/Shanghai"
},
"enabled": true,
"timeout_seconds": 1800,
"misfire_policy": "latest",
"misfire_grace_seconds": 120,
"harness": null,
"cronjob_id": "0e58ff7f7dcbf348c252fc70e7fdb587",
"revision": 1,
"created_at": "2026-09-16T00:00:00Z",
"updated_at": "2026-09-16T00:00:00Z",
"next_run_at": "2026-09-16T01:00:00Z",
"active": null,
"last_run": null
}enabled to false to save a job without starting its scheduleschedule.cron and schedule.at must be non-null. For an enabled one-time task, at must include a timezone offset and lie in the future
Use a stable idempotency_key when retrying creation. Identical requests with the same key return the same task and HTTP 201; different input with that key returns 422. Omitting the key creates a new task on every request
harness uses the task override structure shown on this page. Omitted fields inherit deployed settings. Each execution uses a separate session, and its final output is persisted in TOSAuthorizations
Runtime access credential for a service-authenticated Harness, such as a Runtime API key; shared OAuth deployments do not support background scheduled tasks
Body
Request to create a task; undeclared fields are rejected
Task name, 1–128 characters
1 - 128Message sent to the agent on each execution, 1–65536 characters
1 - 65536Trigger schedule
- Schedule
- Schedule
Show child attributes
Show child attributes
Task-specific overrides using the AgentKit CLI deployment format, such as mcp_servers
Show child attributes
Show child attributes
Whether future scheduling is enabled
Execution timeout in seconds; timeout records a failed execution without automatically retrying it
1 <= x <= 10800latest runs the most recent missed occurrence; skip runs it only within the grace period. Neither policy replays every missed occurrence
latest, skip Maximum lateness in seconds allowed by the skip policy
0 <= x <= 86400Optional idempotency key. The same key and request return the same task; reusing a key with different input returns 422. Omission creates a new task each time
1 - 128Response
Success; repeated identical idempotent requests also return 201
Task name, 1–128 characters
1 - 128Message sent to the agent on each execution, 1–65536 characters
1 - 65536Trigger schedule
- Schedule
- Schedule
Show child attributes
Show child attributes
Settings applied to each execution of this task; explicit fields override the deployed agent and omitted fields inherit it
Show child attributes
Show child attributes
Whether future scheduling is enabled
Execution timeout in seconds; timeout records a failed execution without automatically retrying it
1 <= x <= 10800latest runs the most recent missed occurrence; skip runs it only within the grace period. Neither policy replays every missed occurrence
latest, skip Maximum lateness in seconds allowed by the skip policy
0 <= x <= 86400Owning task ID
^[a-f0-9]{32}$Task revision number
Task creation time in UTC
Most recent task update time in UTC
Next scheduled occurrence in UTC; null when no future occurrence remains
The queued or running execution, or an execution whose final result is still being persisted
Show child attributes
Show child attributes
Summary of the most recently persisted historical execution
Show child attributes
Show child attributes