Skip to main content

Scheduled tasks API

Schedule recurring prompts for your agents using cron expressions. You can create, update, list, and delete scheduled tasks through these endpoints.
All scheduled task endpoints require session authentication. Tasks are scoped to the authenticated user — you can only manage tasks for agents you own.

List scheduled tasks

GET /api/scheduled-tasks
Returns all scheduled tasks for the authenticated user, sorted by creation date (newest first).

Query parameters

ParameterTypeRequiredDescription
agentIdstringNoFilter tasks by agent ID

Response

{
  "tasks": [
    {
      "id": "task_abc123",
      "name": "Daily check-in",
      "description": "Morning status update",
      "cronSchedule": "0 9 * * *",
      "prompt": "Give me a morning briefing on today's schedule and priorities.",
      "enabled": true,
      "lastRun": "2026-03-22T09:00:00Z",
      "nextRun": "2026-03-23T09:00:00Z",
      "agentId": "agent_456",
      "createdAt": "2026-03-15T12:00:00Z",
      "updatedAt": "2026-03-22T09:00:00Z"
    }
  ],
  "count": 1
}

Task object

FieldTypeDescription
idstringUnique task identifier
namestringTask name
descriptionstring | nullOptional task description
cronSchedulestringCron expression (5 or 6 fields)
promptstringThe prompt sent to the agent on each run
enabledbooleanWhether the task is active
lastRunstring | nullISO 8601 timestamp of the last execution
nextRunstring | nullISO 8601 timestamp of the next scheduled execution
agentIdstringID of the agent this task targets
createdAtstringISO 8601 creation timestamp
updatedAtstringISO 8601 last-updated timestamp

Errors

CodeDescription
401Unauthorized — no valid session
500Failed to list tasks

Create a scheduled task

POST /api/scheduled-tasks
Creates a new scheduled task for one of your agents. The cron schedule is validated to ensure it contains 5 or 6 fields.

Request body

FieldTypeRequiredDescription
namestringYesTask name
cronSchedulestringYesCron expression with 5 or 6 fields (for example, "0 9 * * *" for daily at 9 AM)
promptstringYesThe prompt to send to the agent on each run
agentIdstringYesID of the agent to target. Must belong to you.
descriptionstringNoOptional description
enabledbooleanNoWhether the task starts active. Defaults to true.

Example request

{
  "name": "Weekly fan report",
  "cronSchedule": "0 10 * * 1",
  "prompt": "Generate a weekly fan engagement report with streaming stats and growth trends.",
  "agentId": "agent_456",
  "description": "Runs every Monday at 10 AM"
}

Response (201 Created)

Returns the created task object.

Errors

CodeDescription
400Missing required fields (name, cronSchedule, prompt, and agentId are required)
400Invalid cron schedule (expected 5–6 fields)
401Unauthorized — no valid session
404Agent not found or does not belong to you
500Task creation failed

Update a scheduled task

PUT /api/scheduled-tasks
Updates an existing scheduled task. Only the fields you include in the request body are changed.

Request body

FieldTypeRequiredDescription
taskIdstringYesID of the task to update
namestringNoUpdated task name
descriptionstringNoUpdated description
cronSchedulestringNoUpdated cron expression
promptstringNoUpdated prompt
enabledbooleanNoEnable or disable the task

Example request

{
  "taskId": "task_abc123",
  "enabled": false
}

Response

Returns the updated task object.

Errors

CodeDescription
400taskId is required
401Unauthorized — no valid session
404Task not found or does not belong to you
500Task update failed

Delete a scheduled task

DELETE /api/scheduled-tasks
Permanently deletes a scheduled task.

Request body

FieldTypeRequiredDescription
taskIdstringYesID of the task to delete

Response

{
  "success": true,
  "taskId": "task_abc123"
}

Errors

CodeDescription
400taskId is required
401Unauthorized — no valid session
404Task not found or does not belong to you
500Task deletion failed