Skip to main content
The Agent API is the same interface the Aspect web app uses to power its AI assistant. You can use it to build your own integrations: create a conversation, send a message to start a run, stream the assistant’s events over SSE, and approve or reject any tool calls that require confirmation. All endpoints live under https://api.aspect.inc/agent and authenticate with an sk_ API key like the rest of the REST API.

Lifecycle

1

Create a conversation

POST /agent/conversations creates a conversation scoped to a workspace (and optionally a project).
2

Start a run

POST /agent/conversations/{conversation_id}/runs sends a user message. The response is a Server-Sent Events stream of the run as it executes.
3

Follow events

GET /agent/conversations/{conversation_id}/events/stream streams the conversation’s event log from any cursor - useful for reconnecting or observing from a second client.
4

Handle approvals

When a run pauses with requires_approval, submit a decision with POST /agent/runs/{run_id}/approvals/{approval_id}, then resume the run.

Create a conversation

workspace_id is required (unless you pass share_id for a share-scoped conversation). project_id and title are optional. The response (201) includes the conversation id, scope, status, and timestamps. Related conversation endpoints:
  • GET /agent/conversations?workspace_id=...&offset=0&limit=50: list conversations in a scope; supports optional project_id or share_id, returns conversations and has_more.
  • GET /agent/conversations/{conversation_id}: hydrate a conversation, returning its metadata plus full messages, runs, and tool_calls.
  • PATCH /agent/conversations/{conversation_id}: update the title.

Start a run

Send a user message. The connection stays open and returns the run’s events as an SSE stream (Content-Type: text/event-stream):
The request body accepts:

Stream and list events

Every conversation has an ordered event log with a monotonically increasing integer cursor, so you can resume from wherever you left off:
Event types include run.created, run.status_changed, text.delta, text.completed, tool_call.created, tool_call.updated, tool_call.completed, approval.required, and approval.resolved. Each event carries its cursor, event_type, and a JSON payload. For polling instead of streaming, GET /agent/conversations/{conversation_id}/events?after_cursor=0&limit=100 returns a page of events with has_more and latest_cursor.
For SSE endpoints, the API key can also be passed as an authorization query parameter when your client cannot set request headers.

Approvals

Tools with side effects (creating share links, moving files, and so on) can pause the run with status requires_approval. The approval.required event carries the tool call details and an approval ID. Submit a decision:
decision is approve or reject, with an optional note. The response is the updated run. After deciding, resume the run to continue execution.

Resume and cancel

Resume a paused run - the response is a fresh SSE stream of the continuing run:
Cancel a run:

Run statuses

A run moves through these statuses, reported via run.status_changed events and on run responses: pendingrunning → (requires_approval | paused) → completed | failed | cancel_requestedcancelled The assistant has the same tool set and permission checks as the in-app experience - it can only see and change what your API key’s user can.