Documentation Index
Fetch the complete documentation index at: https://docs.crewship.ai/llms.txt
Use this file to discover all available pages before exploring further.
All mission endpoints require authentication and workspace context.
List All Missions (Workspace)
GET /api/v1/missions?workspace_id={workspaceId}
List all missions across the workspace.
Query Parameters:
| Parameter | Type | Default | Description |
|---|
workspace_id | string | Required | Workspace ID |
status | string | — | Filter by status (e.g., IN_PROGRESS) |
include_tasks | string | "false" | Set to "true" to include task details |
limit | integer | 20 | Max items (1-100) |
offset | integer | 0 | Pagination offset |
Response: 200 OK
[
{
"id": "mission_abc",
"workspace_id": "ws_123",
"crew_id": "crew_456",
"lead_agent_id": "agent_789",
"lead_agent_name": "Tech Lead",
"lead_agent_slug": "tech-lead",
"trace_id": "mission-cm1abc123",
"title": "Implement user authentication",
"description": "Add JWT-based auth with refresh tokens",
"status": "IN_PROGRESS",
"plan": "1. Create auth middleware\n2. Add login endpoint...",
"workflow_template": null,
"total_token_count": 15000,
"total_estimated_cost": 0.45,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T11:00:00Z",
"completed_at": null,
"task_stats": {
"total": 4,
"pending": 1,
"blocked": 0,
"in_progress": 1,
"completed": 2,
"failed": 0,
"skipped": 0,
"awaiting_approval": 0
},
"tasks": []
}
]
List Crew Missions
GET /api/v1/crews/{crewId}/missions?workspace_id={workspaceId}
Query Parameters:
| Parameter | Type | Default | Description |
|---|
status | string | — | Filter by status |
limit | integer | 20 | Max items (1-100) |
offset | integer | 0 | Pagination offset |
Response: 200 OK — array of mission objects with task_stats.
Create Mission
POST /api/v1/crews/{crewId}/missions?workspace_id={workspaceId}
Auth: OWNER, ADMIN, or MANAGER role
Request Body:
| Field | Type | Required | Description |
|---|
title | string | Yes | Mission title |
description | string | No | Mission description |
lead_agent_id | string | Yes | ID of the LEAD agent in the crew |
workflow_template | string | No | Workflow template ID to use |
{
"title": "Implement user authentication",
"description": "Add JWT-based auth with refresh tokens",
"lead_agent_id": "agent_789"
}
The lead agent must exist in the specified crew and have the LEAD role.
Response: 201 Created — mission object with status PLANNING.
| Status | Condition |
|---|
400 | Missing title, missing/invalid lead_agent_id, agent not LEAD role |
403 | Insufficient role |
WebSocket events: mission.created on crew:{crewId}, mission.updated on workspace:{workspaceId}
Get Mission
GET /api/v1/crews/{crewId}/missions/{missionId}?workspace_id={workspaceId}
Returns the mission with all tasks and task stats.
Response: 200 OK
{
"id": "mission_abc",
"title": "Implement user authentication",
"status": "IN_PROGRESS",
"tasks": [
{
"id": "task_001",
"mission_id": "mission_abc",
"assigned_agent_id": "agent_dev1",
"agent_name": "Backend Dev",
"agent_slug": "backend-dev",
"title": "Create auth middleware",
"description": "Implement JWT validation middleware",
"status": "COMPLETED",
"task_order": 1,
"depends_on": "[]",
"iteration": 1,
"max_iterations": 3,
"result_summary": "Created middleware with token validation",
"output_path": "/workspace/internal/auth/middleware.go",
"error_message": null,
"assignment_id": "assign_abc",
"token_count": 5000,
"estimated_cost": 0.15,
"started_at": "2024-01-15T10:05:00Z",
"completed_at": "2024-01-15T10:15:00Z",
"duration_ms": 600000,
"confidence": 0.95,
"needs_review": false,
"handoff_context": null,
"evaluation_status": "PASS",
"evaluation_notes": null,
"approval_required": false,
"approval_status": null,
"approved_by": null,
"approved_at": null,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:15:00Z"
}
],
"task_stats": { ... }
}
| Status | Condition |
|---|
404 | Mission not found |
Update Mission
PATCH /api/v1/crews/{crewId}/missions/{missionId}?workspace_id={workspaceId}
Auth: OWNER, ADMIN, or MANAGER role
Request Body: All fields optional.
| Field | Type | Description |
|---|
title | string | Mission title |
description | string | Mission description |
plan | string | Mission plan (markdown) |
status | string | New status (must be a valid transition) |
Status Transitions:
| From | Allowed To |
|---|
PLANNING | IN_PROGRESS, CANCELLED |
IN_PROGRESS | REVIEW, FAILED, CANCELLED |
REVIEW | COMPLETED, IN_PROGRESS, FAILED, CANCELLED |
When status changes to COMPLETED, FAILED, or CANCELLED, completed_at is automatically set.
Response: 200 OK — updated mission object.
| Status | Condition |
|---|
400 | Invalid status transition |
404 | Mission not found |
Delete Mission
DELETE /api/v1/crews/{crewId}/missions/{missionId}?workspace_id={workspaceId}
Only missions in PLANNING or CANCELLED status can be deleted (hard delete).
Auth: OWNER, ADMIN, or MANAGER role
Response: 204 No Content
| Status | Condition |
|---|
400 | Mission is not in PLANNING or CANCELLED status |
404 | Mission not found |
Start Mission
POST /api/v1/crews/{crewId}/missions/{missionId}/start?workspace_id={workspaceId}
Transitions a PLANNING mission to IN_PROGRESS and starts the MissionEngine.
Validates the task dependency DAG before starting. Uses atomic compare-and-swap to prevent concurrent start races.
Auth: OWNER, ADMIN, or MANAGER role
Response: 200 OK
{
"id": "mission_abc",
"status": "IN_PROGRESS"
}
| Status | Condition |
|---|
400 | Mission not in PLANNING state, or invalid task DAG |
404 | Mission not found |
409 | Mission was already started by another request |
500 | MissionEngine failed to start (rolls back to PLANNING) |
Restart Mission
POST /api/v1/crews/{crewId}/missions/{missionId}/restart?workspace_id={workspaceId}
Restarts a COMPLETED, FAILED, or CANCELLED mission. Resets non-COMPLETED tasks (PENDING if dependencies allow, BLOCKED otherwise), increments their iteration, clears errors, and moves the mission back to PLANNING (call start afterwards to dispatch). (internal/api/task_state.go:14)
Auth: OWNER, ADMIN, or MANAGER role
Response: 200 OK
{ "id": "mission_abc", "status": "PLANNING" }
| Status | Condition |
|---|
404 | Mission not found |
409 | Mission is not in a terminal state (COMPLETED/FAILED/CANCELLED) |
Resume Mission
POST /api/v1/crews/{crewId}/missions/{missionId}/resume?workspace_id={workspaceId}
Resumes a FAILED mission from the point of failure. The handler atomically claims the mission into RESUMING, resets the FAILED/AWAITING_APPROVAL tasks plus their downstream dependents, validates the DAG, and re-engages the MissionEngine. COMPLETED tasks are preserved. (internal/api/task_state.go:103)
Auth: OWNER, ADMIN, or MANAGER role
Response: 200 OK
| Status | Condition |
|---|
400 | No failed tasks to resume from, or invalid DAG |
404 | Mission not found |
409 | Mission is not currently FAILED |
Clone Mission
POST /api/v1/crews/{crewId}/missions/{missionId}/clone?workspace_id={workspaceId}
Creates a copy of the mission with all its tasks, resetting statuses to PLANNING/PENDING (or BLOCKED if the cloned task carries dependencies).
Auth: OWNER, ADMIN, or MANAGER role
Response: 201 Created
{ "id": "mission_new", "status": "PLANNING" }
The handler returns the new mission id and status only; fetch GET /api/v1/crews/{crewId}/missions/{newId} for the full mission object (internal/api/task_state.go:472).
Create Task
POST /api/v1/crews/{crewId}/missions/{missionId}/tasks?workspace_id={workspaceId}
Add a task to a mission.
Auth: OWNER, ADMIN, or MANAGER role
Request Body: (internal/api/task_handler.go:42)
| Field | Type | Required | Default | Description |
|---|
title | string | Yes | — | Task title |
description | string | No | null | Task description |
assigned_agent_id | string | No | null | Agent to assign to |
task_order | integer | No | 0 | Position in task list |
depends_on | string[] | No | [] | Array of task IDs this depends on |
max_iterations | integer | No | null | Max retry iterations |
Tasks can only be added to missions in PLANNING or IN_PROGRESS state. If any dependency task is not COMPLETED, the new task is created with status BLOCKED; otherwise PENDING.
Response: 201 Created
Update Task
PATCH /api/v1/crews/{crewId}/missions/{missionId}/tasks/{taskId}?workspace_id={workspaceId}
Request Body: All fields optional. (internal/api/task_handler.go:146)
| Field | Type | Description |
|---|
title | string | Task title (PENDING/BLOCKED only) |
description | string | Task description (PENDING/BLOCKED only) |
assigned_agent_id | string | Reassign to a different agent |
status | string | New status (valid transition required) |
depends_on | string | JSON-encoded dependency task IDs (PENDING/BLOCKED only) |
result_summary | string | Result summary text |
error_message | string | Error message text |
output_path | string | Output file path |
token_count | integer | Token usage |
estimated_cost | number | Estimated cost in USD |
status and depends_on cannot be set in the same request — the handler returns 400 with “Cannot update status and depends_on in the same request” (internal/api/task_handler.go:359). task_order, max_iterations, and approval_required are not currently mutable through this endpoint.
Task Status Transitions:
| From | Allowed To |
|---|
PENDING | IN_PROGRESS, SKIPPED |
BLOCKED | PENDING, SKIPPED |
IN_PROGRESS | COMPLETED, FAILED, SKIPPED |
Response: 200 OK
Mission Metrics
GET /api/v1/mission-metrics?workspace_id={workspaceId}
Aggregated mission metrics for the workspace, covering the last 24 hours.
Response: 200 OK
{
"total_missions": 45,
"active_missions": 3,
"completed_24h": 8,
"failed_24h": 1,
"total_tokens_24h": 125000,
"total_cost_24h": 3.75,
"avg_completion_time_ms": 180000,
"tasks_completed_24h": 24,
"tasks_failed_24h": 2
}
Mission Statuses
| Status | Description |
|---|
PLANNING | Lead is analyzing and creating task breakdown |
IN_PROGRESS | Agents are working on tasks |
REVIEW | All tasks done, lead is reviewing results |
COMPLETED | Successfully finished |
FAILED | Unresolvable problem encountered |
CANCELLED | Cancelled by user or system |
Task Statuses
| Status | Description |
|---|
PENDING | Not yet started, waiting for dependencies |
BLOCKED | Blocked by unfinished dependency tasks |
IN_PROGRESS | Agent is currently working on it |
COMPLETED | Successfully finished |
FAILED | Agent failed the task |
SKIPPED | Manually skipped |
AWAITING_APPROVAL | Waiting for human approval |