Schedules API
Schedules enable automated task execution at specific times or intervals. Create one-time tasks or recurring schedules using cron expressions.
The Schedule Object
{
"id": "sched_abc123",
"userId": "user_xxx",
"name": "Daily Cleanup",
"description": "Clean temp files every morning",
"task": "Delete all files in /tmp older than 24 hours",
"agentId": "agent_xxx",
"environmentId": "env_xxx",
"scheduleType": "recurring",
"cronExpression": "0 9 * * *",
"timezone": "America/New_York",
"enabled": true,
"nextRunAt": "2025-01-16T09:00:00Z",
"lastRunAt": "2025-01-15T09:00:00Z",
"runCount": 15,
"successCount": 14,
"failureCount": 1,
"createdAt": "2025-01-01T10:00:00Z",
"updatedAt": "2025-01-15T09:00:00Z"
}Attributes
| Attribute | Type | Description |
|---|---|---|
id | string | Unique identifier (sched_*) |
userId | string | Owner user ID |
name | string | Schedule name |
description | string | Optional description |
task | string | Task to execute |
agentId | string | Agent to use |
environmentId | string | Environment for execution |
scheduleType | string | one-time or recurring |
cronExpression | string | Cron expression (recurring only) |
scheduledTime | string | ISO timestamp (one-time only) |
timezone | string | Timezone for scheduling |
enabled | boolean | Whether schedule is active |
nextRunAt | string | Next scheduled execution |
lastRunAt | string | Last execution time |
runCount | number | Total executions |
successCount | number | Successful executions |
failureCount | number | Failed executions |
Create Schedule
POST /v1/schedulesRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Schedule name |
task | string | Yes | Task to execute |
scheduleType | string | Yes | one-time or recurring |
cronExpression | string | For recurring | Cron expression |
scheduledTime | string | For one-time | ISO 8601 timestamp |
agentId | string | No | Agent to use |
environmentId | string | No | Environment for execution |
timezone | string | No | Timezone (default: UTC) |
enabled | boolean | No | Enable immediately (default: true) |
description | string | No | Optional description |
metadata | object | No | Custom metadata |
Example: Recurring Schedule
curl -X POST https://api.computer-agents.com/v1/schedules \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Daily Report",
"task": "Generate and email the daily metrics report",
"scheduleType": "recurring",
"cronExpression": "0 9 * * *",
"timezone": "America/New_York",
"agentId": "agent_xxx"
}'Example: One-Time Schedule
curl -X POST https://api.computer-agents.com/v1/schedules \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Deploy to Production",
"task": "Run deployment script for version 2.0",
"scheduleType": "one-time",
"scheduledTime": "2025-01-20T03:00:00Z"
}'Response
{
"schedule": {
"id": "sched_abc123",
"name": "Daily Report",
"scheduleType": "recurring",
"cronExpression": "0 9 * * *",
"timezone": "America/New_York",
"enabled": true,
"nextRunAt": "2025-01-16T14:00:00Z",
"runCount": 0,
"successCount": 0,
"failureCount": 0,
"createdAt": "2025-01-15T10:00:00Z"
}
}Cron Expression Guide
Cron expressions define when recurring schedules run:
┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-6, Sun=0)
│ │ │ │ │
* * * * *Common Examples
| Expression | Description |
|---|---|
0 9 * * * | Every day at 9:00 AM |
0 9 * * 1-5 | Weekdays at 9:00 AM |
0 */2 * * * | Every 2 hours |
0 9 1 * * | First day of each month at 9:00 AM |
30 14 * * 0 | Sundays at 2:30 PM |
0 0 * * * | Midnight every day |
All times are interpreted in the schedule’s timezone. Default is UTC.
List Schedules
GET /v1/schedulesQuery Parameters
| Parameter | Type | Description |
|---|---|---|
agentId | string | Filter by agent |
environmentId | string | Filter by environment |
appId | string | Filter by app |
scheduleType | string | one-time or recurring |
enabled | boolean | Filter by enabled status |
limit | number | Max results |
offset | number | Pagination offset |
Example
curl "https://api.computer-agents.com/v1/schedules?enabled=true" \
-H "Authorization: Bearer $API_KEY"Response
{
"object": "list",
"data": [
{
"id": "sched_abc123",
"name": "Daily Report",
"scheduleType": "recurring",
"enabled": true,
"nextRunAt": "2025-01-16T14:00:00Z"
}
],
"has_more": false,
"total_count": 5,
"stats": {
"total": 5,
"enabled": 3,
"disabled": 2
}
}Get Schedule
GET /v1/schedules/:idResponse
{
"schedule": {
"id": "sched_abc123",
"name": "Daily Report",
"task": "Generate and email the daily metrics report",
"scheduleType": "recurring",
"cronExpression": "0 9 * * *",
"timezone": "America/New_York",
"enabled": true,
"nextRunAt": "2025-01-16T14:00:00Z",
"lastRunAt": "2025-01-15T14:00:00Z",
"runCount": 15,
"successCount": 14,
"failureCount": 1
}
}Update Schedule
PATCH /v1/schedules/:idRequest Body
| Parameter | Type | Description |
|---|---|---|
name | string | New name |
task | string | New task |
cronExpression | string | New cron expression |
timezone | string | New timezone |
enabled | boolean | Enable/disable |
Example
curl -X PATCH https://api.computer-agents.com/v1/schedules/sched_abc123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"cronExpression": "0 10 * * *"}'Delete Schedule
DELETE /v1/schedules/:idExample
curl -X DELETE https://api.computer-agents.com/v1/schedules/sched_abc123 \
-H "Authorization: Bearer $API_KEY"Trigger Schedule Manually
Run a schedule immediately, regardless of its next scheduled time.
POST /v1/schedules/:id/triggerExample
curl -X POST https://api.computer-agents.com/v1/schedules/sched_abc123/trigger \
-H "Authorization: Bearer $API_KEY"Response
{
"thread": {
"id": "thread_xxx",
"status": "running"
},
"message": "Schedule triggered - execution started"
}Enable/Disable Schedule
Enable
PATCH /v1/schedules/:id/enableDisable
PATCH /v1/schedules/:id/disableResponse
{
"schedule": {
"id": "sched_abc123",
"enabled": true
}
}Schedule via Thread Creation
You can also create schedules when creating threads:
curl -X POST https://api.computer-agents.com/v1/threads \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [{ "role": "user", "content": "Run database backup" }],
"schedule": {
"type": "recurring",
"name": "Nightly Backup",
"cronExpression": "0 2 * * *"
}
}'This creates both the thread and schedule in one request.
Errors
| Status | Error | Description |
|---|---|---|
| 400 | Bad Request | Invalid cron expression or parameters |
| 402 | Payment Required | Insufficient budget for execution |
| 404 | Not Found | Schedule not found |
Related
Last updated on