Goals API
Canonical reference: docs/api-reference.md (generated endpoint directory) — this page is a task-oriented summary.
Goal CRUD with workflow integration. Goals are persistent objectives that drive multi-step agent workflows.
Overview
Goals represent long-running, multi-step tasks managed by the workflow engine. Each goal spawns a coordinator process that decomposes the goal into steps, dispatches sub-agents, and tracks completion. Goals are ETS-only per-node projection state with a supervisor-anchored heir chain: an owner crash preserves them, but they do not survive a node reboot (the accepted loss window — no Mnesia copy, no replay).
Authentication
Requires Authorization: Bearer <token>. Goals are scoped to the authenticated user — non-admin users can only access their own goals.
Endpoints
Create Goal
POST /api/v1/goals
Admin only. Creates a goal from an objective and a task list. The objective is decomposed and dispatched to the workflow engine. Non-admin callers receive 403 {"ok":false,"error":{"code":"forbidden","message":"forbidden"}}.
Request Body:
{
"objective": "Research quantum computing advances in 2026",
"tasks": ["Survey 2026 Q1 papers", "Summarize error-correction progress"]
}
objective is required (400 if empty); tasks is the list of subtasks to decompose and run.
Response (201):
{
"id": "goal-abc123",
"objective": "Research quantum computing advances in 2026",
"status": "in_progress",
"strategy": "parallel",
"subtask_count": 2,
"workflow_ids": ["wf-def456", "wf-def789"]
}
List Goals
GET /api/v1/goals
Returns goals for the authenticated user (admins see all). Each entry is {id, objective, status, meta?}.
{
"goals": [
{"id": "goal-abc123", "objective": "Research quantum computing", "status": "in_progress"}
]
}
Get Goal Details
GET /api/v1/goals/:id
Returns the goal’s coordinator status (current step, step history, results). Owner/admin only.
Update Goal
PUT /api/v1/goals/:id
Update goal metadata. Admin only, or the goal owner for their own goals.
Cancel Goal
POST /api/v1/goals/:id/cancel
DELETE /api/v1/goals/:id
Cancels a running goal. POST /cancel is admin-only; DELETE is allowed for the goal owner or admin. Stops the associated workflows and any in-progress sub-agents.
{
"cancelled": "goal-abc123"
}
Workflow Integration:
Each goal creates a workflow with the following lifecycle:
Created → Decomposing → Step N Running → Step N Complete → ... → Completed
↓
Failed (retry configurable)
↓
Max retries exceeded → Failed
The goal projector (sol_goal_projector) maintains secondary indexes mapping workflow_id → goal_ids for O(1) lookup during event processing.
Error Codes:
| Code | Description |
|---|---|
| 400 | Invalid goal parameters |
| 401 | Authentication required |
| 403 | Not the goal owner (non-admin) |
| 404 | Goal not found |
| 409 | Goal already completed or cancelled |
Examples:
curl -X POST http://127.0.0.1:21434/api/v1/goals \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"objective": "Write unit tests", "tasks": ["Cover the goals module", "Cover the workflow module"]}'
curl http://127.0.0.1:21434/api/v1/goals \
-H "Authorization: Bearer $TOKEN"
curl -X POST http://127.0.0.1:21434/api/v1/goals/goal-abc123/cancel \
-H "Authorization: Bearer $TOKEN"