Skip to main content

Tasks API

Create, schedule, and manage agent tasks. Tasks are units of work assigned to agents -- they can be one-time, scheduled (cron), or triggered by events.

Base path: /api/v1/tasks

Endpoints

List Tasks

GET /api/v1/tasks
ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerResults per page (default: 20, max: 100)
agentIdstringFilter by assigned agent
teamIdstringFilter by team
statusstringpending, running, completed, failed, cancelled
typestringone_time, scheduled, triggered

Response:

{
"tasks": [
{
"id": "task_abc123",
"name": "Daily Pipeline Briefing",
"description": "Generate a summary of pipeline changes",
"agentId": "agent_456",
"teamId": "team_789",
"type": "scheduled",
"schedule": "0 9 * * 1-5",
"status": "completed",
"lastRunAt": "2026-04-12T09:00:00Z",
"nextRunAt": "2026-04-13T09:00:00Z",
"createdAt": "2026-04-01T10:00:00Z"
}
],
"total": 15
}

Create Task

POST /api/v1/tasks
FieldTypeRequiredDescription
namestringYesTask name
descriptionstringYesWhat the agent should do
agentIdstringYesAssigned agent
teamIdstringNoTeam context
appIdstringNoWorkspace scope
typestringNoone_time (default), scheduled, triggered
schedulestringNoCron expression (required for scheduled type)
prioritystringNolow, medium (default), high, critical
dueAtstringNoISO deadline for one-time tasks
inputobjectNoAdditional context for the agent

Example -- Scheduled Task:

{
"name": "Weekly Compliance Report",
"description": "Audit all agent actions from the past week and generate a compliance summary",
"agentId": "agent_compliance",
"type": "scheduled",
"schedule": "0 8 * * 1",
"priority": "high"
}

Response (201):

{
"id": "task_new456",
"name": "Weekly Compliance Report",
"status": "pending",
"type": "scheduled",
"schedule": "0 8 * * 1",
"nextRunAt": "2026-04-14T08:00:00Z",
"createdAt": "2026-04-12T15:00:00Z"
}

Get Task

GET /api/v1/tasks/:id

Returns full task details including run history and output.

Run Task

POST /api/v1/tasks/:id/run

Manually trigger a task execution (even for scheduled tasks). The agent executes the task description as a message.

FieldTypeDescription
inputobjectOptional override context

Response:

{
"runId": "run_789",
"status": "running",
"startedAt": "2026-04-12T15:30:00Z"
}

Cancel Task

POST /api/v1/tasks/:id/cancel

Cancels a running task. If the agent is mid-execution, it stops at the next tool boundary.

Retry Task

POST /api/v1/tasks/:id/retry

Re-runs a failed task with the same configuration.

Delete Task

DELETE /api/v1/tasks/:id

Removes the task. Scheduled tasks stop recurring. Run history is preserved in audit logs.

Task Runs

GET /api/v1/tasks/:id/runs

Returns execution history for a task.

Response:

{
"runs": [
{
"id": "run_001",
"status": "completed",
"output": "Weekly compliance report generated. 3 policy violations flagged.",
"cost": 0.012,
"duration": 8500,
"tokenUsage": { "inputTokens": 3200, "outputTokens": 890 },
"startedAt": "2026-04-07T08:00:00Z",
"completedAt": "2026-04-07T08:00:08Z"
}
]
}

Get Run Details

GET /api/v1/tasks/runs/:runId

Returns full details for a specific run including tool calls and intermediate steps.

Approval Queue

GET /api/v1/tasks/pending-approval

Returns tasks waiting for human approval before execution.

POST /api/v1/tasks/:id/approve
POST /api/v1/tasks/:id/reject

Approve or reject a pending task. Rejected tasks are marked as cancelled.

Common Cron Patterns

PatternSchedule
0 9 * * 1-5Weekdays at 9:00 AM
0 */2 * * *Every 2 hours
0 8 * * 1Mondays at 8:00 AM
0 0 1 * *First of every month at midnight
*/30 * * * *Every 30 minutes

Common Patterns

Create a Daily Briefing

curl -X POST https://app.meetloyd.com/api/v1/tasks \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Daily Pipeline Briefing",
"description": "Summarize new leads, deal updates, and upcoming meetings for today. Post the briefing to the #sales Slack channel.",
"agentId": "agent_sales_lead",
"type": "scheduled",
"schedule": "0 8 * * 1-5",
"priority": "high"
}'

One-Time Research Task

curl -X POST https://app.meetloyd.com/api/v1/tasks \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Competitor Analysis: Acme Corp",
"description": "Research Acme Corp recent announcements, product changes, and market positioning. Create a 1-page summary document.",
"agentId": "agent_research",
"type": "one_time",
"priority": "medium",
"dueAt": "2026-04-15T17:00:00Z"
}'