API Reference

The Optio API is a REST API served by Fastify. All endpoints are prefixed with /api and return JSON. Request bodies use JSON with Zod schema validation.

Info

All endpoints except /api/health, /api/auth/*, and /api/setup/* require authentication via the optio_session cookie or a ?token= query parameter.

Health

MethodEndpointDescription
GET/api/healthHealth check endpoint (no auth required)

Tasks

Tasks are the core resource. Each task represents an agent run against a repository.

MethodEndpointDescription
GET/api/tasksList tasks (filterable by state, repo, type)
POST/api/tasksCreate a new task
GET/api/tasks/:idGet task details
PATCH/api/tasks/:idUpdate a task
DELETE/api/tasks/:idDelete a task
POST/api/tasks/:id/cancelCancel a running or queued task
POST/api/tasks/:id/retryRetry a failed task
POST/api/tasks/:id/resumeResume a needs_attention or failed task with new context
POST/api/tasks/:id/force-restartFresh agent session on existing PR branch
POST/api/tasks/:id/force-redoClear everything and re-run from scratch
POST/api/tasks/:id/reviewManually launch a code review agent
POST/api/tasks/reorderReorder task priorities by position

Create Task Example

POST /api/tasks
{
  "title": "Add user avatar support",
  "prompt": "Add avatar upload and display to user profiles",
  "repoUrl": "https://github.com/acme/webapp",
  "repoBranch": "main",
  "agentType": "claude",
  "priority": 0
}

Bulk Operations

MethodEndpointDescription
POST/api/tasks/bulk/retry-failedRetry all failed tasks
POST/api/tasks/bulk/cancel-activeCancel all running and queued tasks

Subtasks

Tasks can have child tasks. Three subtask types are supported: child (independent), step (sequential pipeline), and review (code review).

MethodEndpointDescription
GET/api/tasks/:id/subtasksList subtasks of a task
POST/api/tasks/:id/subtasksCreate a subtask (child, step, or review)
GET/api/tasks/:id/subtasks/statusGet subtask completion status

Task Comments

MethodEndpointDescription
GET/api/tasks/:id/commentsList comments on a task
POST/api/tasks/:id/commentsAdd a comment to a task

Task Dependencies

MethodEndpointDescription
GET/api/tasks/:id/dependenciesList task dependencies
POST/api/tasks/:id/dependenciesAdd a dependency (task must complete before this task starts)
DELETE/api/tasks/:id/dependencies/:depIdRemove a dependency

Repositories

Manage connected repositories and their per-repo settings.

MethodEndpointDescription
GET/api/reposList connected repositories
POST/api/reposConnect a new repository
GET/api/repos/:idGet repository details and settings
PATCH/api/repos/:idUpdate repository settings
DELETE/api/repos/:idDisconnect a repository

Issues

Browse and assign GitHub Issues from connected repositories.

MethodEndpointDescription
GET/api/issuesList GitHub Issues across all connected repos
POST/api/issues/assignAssign a GitHub Issue to Optio (creates a task)

Tickets

Manage external ticket provider integrations (GitHub Issues, Linear).

MethodEndpointDescription
GET/api/tickets/providersList configured ticket providers
POST/api/tickets/providersAdd a ticket provider
PATCH/api/tickets/providers/:idUpdate a ticket provider
DELETE/api/tickets/providers/:idRemove a ticket provider
POST/api/tickets/syncTrigger a manual ticket sync

Interactive Sessions

Sessions provide persistent, interactive workspaces connected to repo pods with terminal and agent chat.

MethodEndpointDescription
GET/api/sessionsList sessions (filterable by state, repo)
POST/api/sessionsCreate an interactive session
GET/api/sessions/:idGet session details
POST/api/sessions/:id/endEnd a session and clean up worktree

Sessions also expose WebSocket endpoints:

  • WS /ws/sessions/:id/terminal — xterm.js interactive terminal
  • WS /ws/sessions/:id/chat — interactive Claude Code chat

Secrets

MethodEndpointDescription
GET/api/secretsList secrets (names and scopes only, never values)
POST/api/secretsCreate or update a secret
DELETE/api/secrets/:nameDelete a secret

Warning

Secret values are never returned by the API. Only names and scopes are exposed. Secrets are encrypted at rest with AES-256-GCM.

Authentication

MethodEndpointDescription
GET/api/auth/providersList enabled OAuth providers (no auth required)
GET/api/auth/:provider/loginInitiate OAuth flow (redirects to provider)
GET/api/auth/:provider/callbackOAuth callback (sets session cookie)
GET/api/auth/meGet current user profile
POST/api/auth/logoutRevoke session and clear cookie
GET/api/auth/statusClaude subscription status
GET/api/auth/usageClaude Max/Pro usage metrics

Workspaces

Multi-tenancy via workspaces. Resources are scoped to the active workspace.

MethodEndpointDescription
GET/api/workspacesList workspaces for the current user
POST/api/workspacesCreate a new workspace
PATCH/api/workspaces/:idUpdate workspace settings
GET/api/workspaces/:id/membersList workspace members
POST/api/workspaces/:id/membersInvite a member to the workspace

Prompt Templates

MethodEndpointDescription
GET/api/prompt-templatesList prompt templates
POST/api/prompt-templatesCreate a prompt template
PATCH/api/prompt-templates/:idUpdate a prompt template
DELETE/api/prompt-templates/:idDelete a prompt template

Task Templates

MethodEndpointDescription
GET/api/task-templatesList task templates
POST/api/task-templatesCreate a task template
PATCH/api/task-templates/:idUpdate a task template
DELETE/api/task-templates/:idDelete a task template

Analytics

MethodEndpointDescription
GET/api/analytics/costsCost analytics with daily, per-repo, and per-type breakdowns

Query Parameters

ParamDefaultDescription
days30Number of days to aggregate
repoUrlallFilter by repository URL

Response Shape

GET /api/analytics/costs?days=30
{
  "summary": {
    "totalCost": "12.45",
    "taskCount": 38,
    "averageCost": "0.33",
    "costTrend": 15.2
  },
  "dailyCosts": [
    { "date": "2025-01-15", "cost": "1.20", "taskCount": 4 }
  ],
  "costByRepo": [
    { "repoUrl": "https://github.com/acme/webapp", "cost": "8.30" }
  ],
  "costByType": [
    { "taskType": "coding", "cost": "10.15" },
    { "taskType": "review", "cost": "2.30" }
  ],
  "topTasks": [
    { "id": "abc123", "title": "Refactor auth", "costUsd": "1.85" }
  ]
}

Webhooks

MethodEndpointDescription
GET/api/webhooksList configured webhooks
POST/api/webhooksCreate a webhook endpoint
PATCH/api/webhooks/:idUpdate a webhook
DELETE/api/webhooks/:idDelete a webhook

Schedules

MethodEndpointDescription
GET/api/schedulesList scheduled/recurring tasks
POST/api/schedulesCreate a schedule
PATCH/api/schedules/:idUpdate a schedule
DELETE/api/schedules/:idDelete a schedule

Workflows

Multi-step workflow automation with templates and run tracking.

MethodEndpointDescription
GET/api/workflowsList workflow templates
POST/api/workflowsCreate a workflow template
POST/api/workflows/:id/runExecute a workflow
GET/api/workflows/:id/runsList runs for a workflow

Cluster

MethodEndpointDescription
GET/api/cluster/nodesList cluster nodes with resource usage
GET/api/cluster/podsList Optio-managed pods
GET/api/cluster/pods/:name/logsGet pod logs

Slack

MethodEndpointDescription
POST/api/slack/testSend a test Slack notification

MCP Servers

MethodEndpointDescription
GET/api/mcp-serversList MCP server configurations
POST/api/mcp-serversAdd an MCP server (global or per-repo)
PATCH/api/mcp-servers/:idUpdate an MCP server config
DELETE/api/mcp-servers/:idRemove an MCP server

Skills

MethodEndpointDescription
GET/api/skillsList custom agent skills
POST/api/skillsCreate a custom skill
PATCH/api/skills/:idUpdate a skill
DELETE/api/skills/:idDelete a skill

Setup

MethodEndpointDescription
GET/api/setup/statusCheck if initial setup is complete
POST/api/setup/completeComplete the initial setup wizard

WebSocket Endpoints

Real-time communication uses WebSocket connections authenticated via ?token= query parameter.

EndpointDescription
/ws/logs/:taskIdStream real-time structured logs for a task
/ws/eventsGlobal event stream (task state changes, new tasks, etc.)
/ws/sessions/:id/terminalInteractive terminal for a session (xterm.js)
/ws/sessions/:id/chatInteractive Claude Code chat for a session