Skip to content

Hosted Endpoints

This reference lists the ASP.NET Core hosted runtime endpoints at contract level. Routes are relative to the route group prefix configured by MapHPDAgentApi(...). Created-resource Location headers are currently prefixless even when routes are mapped under a prefix.

Endpoint examples use DTO names and status families. Event payload fields are delegated to Events, because exhaustive event schemas should be generated from source rather than hand-authored.

Scope Rules

The hosted runtime scope is:

text
agentId + sessionId + branchId

Routes are intentionally mixed:

  • session routes do not include agentId
  • branch read, update, delete, content, and event-log routes are session/branch scoped
  • branch create, fork, branch runs, input, interrupt, SSE, WebSocket, and the bidirectional response route include agentId
  • stored agent definitions live under /agents

Sessions

MethodRouteBodySuccessCommon failures
POST/sessionsCreateSessionRequest?201 SessionDto400 validation problem
GET/sessionsnone200 List<SessionDto>400
POST/sessions/searchSearchSessionsRequest?200 List<SessionDto>400
GET/sessions/{sessionId}none200 SessionDto404, 400
PATCH/sessions/{sessionId}UpdateSessionRequest200 SessionDto404, 400
DELETE/sessions/{sessionId}none204404, 400

CreateSessionRequest has optional sessionId and metadata. Missing ids are generated. Creating a session creates branch main.

SearchSessionsRequest filters by exact stringified metadata value and supports offset and limit. UpdateSessionRequest merges metadata and removes keys whose values are null.

Branches

MethodRouteBodySuccessCommon failures
GET/sessions/{sid}/branchesnone200 List<BranchDto>404, 400
GET/sessions/{sid}/branches/{bid}none200 BranchDto404, 400
POST/agents/{agentId}/sessions/{sid}/branchesCreateBranchRequest201 BranchDto404, 409, 400
POST/agents/{agentId}/sessions/{sid}/branches/{bid}/forkForkBranchRequest201 BranchDto404, 400
PATCH/sessions/{sid}/branches/{bid}UpdateBranchRequest200 BranchDto404, 400
DELETE/sessions/{sid}/branches/{bid}?recursive=falsenone204404, 409, 400
GET/sessions/{sid}/branches/{bid}/eventsnone200 List<AgentEvent>404, 400
GET/sessions/{sid}/branches/{bid}/siblingsnone200 List<BranchDto>404, 400

ForkBranchRequest has newBranchId, fromMessageId, optional display metadata, tags, and metadata. It does not have a per-request fork-compaction field. Hosted fork compaction is controlled by the configured server-side agent and middleware pipeline.

ForkBranchRequest requires fromMessageId. main is protected from deletion. Recursive deletion requires both recursive=true and server configuration that allows recursive branch delete.

Branch Runs

MethodRouteBodySuccessCommon failures
GET/agents/{agentId}/sessions/{sid}/branches/{bid}/runsnone200 List<BranchRunDto>404, 400
GET/agents/{agentId}/sessions/{sid}/branches/{bid}/runs/activenone200 BranchRunDto?404, 400
GET/agents/{agentId}/sessions/{sid}/branches/{bid}/runs/{runtimeRunId}none200 BranchRunDto404, 400

Branch run status values are currently active, completed, cancelled, and failed.

Only one active hosted branch run is allowed for a given sessionId + branchId.

Agent Definitions

MethodRouteBodySuccessCommon failures
POST/agentsCreateAgentRequest201 StoredAgentDto400
GET/agentsnone200 List<AgentSummaryDto>400
GET/agents/{agentId}none200 StoredAgentDto404, 400
PUT/agents/{agentId}UpdateAgentRequest200 StoredAgentDto404, 400
DELETE/agents/{agentId}none204404, 400

Create and update validate AgentConfig. Listing returns summaries that omit config. Updating or deleting a stored definition evicts cached runtime agents for that agentId.

Content

MethodRouteBodySuccessCommon failures
POST/sessions/{sid}/branches/{bid}/contentmultipart/form-data, field file201 ContentDto404, 400
GET/sessions/{sid}/branches/{bid}/contentnone200 List<ContentDto>404, 400
GET/sessions/{sid}/branches/{bid}/content/{contentId}nonebinary file404, 400
DELETE/sessions/{sid}/branches/{bid}/content/{contentId}none204404, 400

Default hosted content storage is in-memory. Do not assume durability unless the host configures durable content storage.

Streaming And Responses

MethodRouteBody or protocolSuccessCommon failures
POST/agents/{agentId}/sessions/{sid}/branches/{bid}/inputsStreamTextRequest or input event envelope202400, 404, 409, 500
GET/agents/{agentId}/sessions/{sid}/branches/{bid}/events/liveSSEtext/event-stream404 before headers
POST/agents/{agentId}/sessions/{sid}/branches/{bid}/interruptoptional interruption envelope or reason body202404, 409, 400, 500
GET/agents/{agentId}/sessions/{sid}/branches/{bid}/wsWebSocket text framesWebSocket streampre-upgrade 400, 404, 409; post-upgrade invalid-payload or policy-violation close statuses
POST/agents/{agentId}/sessions/{sid}/branches/{bid}/responsesbidirectional response event envelope200404, 409, 400

SSE sends one live event envelope per data: frame. WebSocket accepts text frames containing input envelopes or bidirectional response envelopes and sends live event envelopes back after a valid client frame initializes the subscription. HTTP clients post permission, continuation, clarification, client-tool, or custom bidirectional response envelopes to the single /responses route.

Concurrency

Branch runs and branch operation locks are separate:

  • branch run ownership allows one active hosted run per sessionId + branchId
  • branch operation locks protect exclusive branch mutations such as deletion
  • middleware responses require an active branch runtime but are not branch runs

Built for production .NET agent applications.