API Reference
The Longshot CLI exposes a full REST API for programmatic access. All API routes are validated with Zod schemas and documented via OpenAPI 3.1.
OpenAPI specification
The CLI serves an auto-generated OpenAPI 3.1.0 spec at:
GET http://localhost:3333/api/openapi.json
This spec is the definitive API reference — generated directly from the Zod schemas that validate every request at runtime. Import it into tools like Swagger UI, Postman, or any OpenAPI-compatible client.
Base URL
When running locally:
http://localhost:3333
When connected via the tunnel (through the web service):
https://app.longshothq.com/app/:daemonId
All API endpoints are under the /api prefix.
Tasks
| Method | Route | Description |
GET | /api/tasks | List all tasks |
GET | /api/tasks/:id | Get task detail |
GET | /api/tasks/:id/status | Poll task status (for UI updates) |
POST | /api/tasks/:id/ready | Mark task as ready |
POST | /api/tasks/:id/start | Start work on task |
POST | /api/tasks/:id/cancel | Cancel a task |
POST | /api/tasks/:id/continue | Continue a timed-out task |
Chat
| Method | Route | Description |
GET | /api/chat/messages | Get chat messages (with pagination) |
POST | /api/chat/message | Send a chat message |
POST | /api/chat/draft-task | Draft a new task from a description |
POST | /api/chat/add-service | Add a service via natural language |
Diff review
| Method | Route | Description |
GET | /api/diff/:id | Get pending diff |
POST | /api/diff/:id/approve | Approve and commit changes |
POST | /api/diff/:id/reject | Reject and discard changes |
POST | /api/diff/:id/fix | Request a targeted fix |
Agent
| Method | Route | Description |
GET | /api/agent/:runId/events | Get agent events (with ?after=N for polling) |
Work queue
| Method | Route | Description |
GET | /api/queue | Get queue status (pending/running items) |
DELETE | /api/queue/:id | Remove a pending queue item |
POST | /api/queue/:id/retry | Retry a failed queue item |
Git
| Method | Route | Description |
GET | /api/git/status | Fetch from remote, return ahead/behind counts |
POST | /api/git/push | Push to remote |
POST | /api/git/pull | Pull from remote (supports { rebase: true }) |
Branches
| Method | Route | Description |
GET | /api/branches | List branches with current/active info |
POST | /api/branches | Create a new branch |
POST | /api/branches/switch | Switch to a branch |
POST | /api/branches/:name/push | Push branch to remote |
POST | /api/branches/:name/merge | Merge branch into parent |
DELETE | /api/branches/:name | Delete a merged branch |
Services
| Method | Route | Description |
GET | /api/services | List all services with status |
POST | /api/services | Create a new service |
PUT | /api/services/:id | Update a service definition |
DELETE | /api/services/:id | Delete a service |
POST | /api/services/:id/start | Start service |
POST | /api/services/:id/stop | Stop service |
POST | /api/services/:id/restart | Restart service |
GET | /api/services/:id/logs | Get service log tail |
POST | /api/services/:id/logs/clear | Clear service logs |
Other endpoints
| Method | Route | Description |
GET | /api/spec | Get project spec |
GET | /api/history | Get action history |
GET | /api/run/:id/events | Get run log events |
GET | /api/openapi.json | OpenAPI 3.1 spec |
Request validation
All JSON API routes validate requests at runtime using Zod schemas. Invalid requests receive a 400 response with structured error details:
{
"success": false,
"error": {
"issues": [
{
"code": "invalid_type",
"path": ["message"],
"message": "Required"
}
]
}
}