Agent
For instructions on how to authenticate to use this endpoint, see API overview.
Endpoints
POST | |
POST | |
GET | |
PATCH | |
DELETE | |
GET | |
GET | |
POST | |
POST | |
GET | |
GET | |
POST | |
GET | |
POST | |
POST | |
GET | |
GET | |
GET | |
GET |
Create agent applications revisions validate
Pre-flight checks before freeze + promote: agent.md exists,
every native tool id is registered, every custom tool has its
compiled.js + schema.json, every skill path exists, every declared
secret has a value set in this revision's env block. Returns
{ ok, errors: [...] }. Works on any revision state.
Required API key scopes
agents:readPath parameters
- application_idstring
- idstring
Response
Example request
POST /api /projects /:project_id /agent_applications /:application_id /revisions /:id /validateExample response
Status 200
Create agent applications revisions new draft
Create a fresh draft revision under application_id and seed it
from source_revision_id. Saves the MCP one round-trip vs the
explicit create + clone_from sequence.
Required API key scopes
agents:writePath parameters
- application_idstring
Request parameters
- application_idstring
- source_revision_idstring
Response
Example request
POST /api /projects /:project_id /agent_applications /:application_id /revisions /new_draftExample response
Status 200
Retrieve agent applications
Agent applications — the deployable unit of the platform.
URLs: GET /api/projects/<team>/agent_applications/ list POST /api/projects/<team>/agent_applications/ create GET /api/projects/<team>/agent_applications/<id|slug>/ retrieve PATCH /api/projects/<team>/agent_applications/<id|slug>/ update DELETE /api/projects/<team>/agent_applications/<id|slug>/ archive POST /api/projects/<team>/agent_applications/<id|slug>/set_env/ bulk replace env GET /api/projects/<team>/agent_applications/<id|slug>/env_keys/ list set keys GET /api/projects/<team>/agent_applications/<id|slug>/env_keys/<KEY>/ is one key set? PUT /api/projects/<team>/agent_applications/<id|slug>/env_keys/<KEY>/ set one key DELETE /api/projects/<team>/agent_applications/<id|slug>/env_keys/<KEY>/ clear one key
Required API key scopes
agents:readPath parameters
- idstring
Response
Example request
GET /api /projects /:project_id /agent_applications /:idExample response
Status 200
Update agent applications
Agent applications — the deployable unit of the platform.
URLs: GET /api/projects/<team>/agent_applications/ list POST /api/projects/<team>/agent_applications/ create GET /api/projects/<team>/agent_applications/<id|slug>/ retrieve PATCH /api/projects/<team>/agent_applications/<id|slug>/ update DELETE /api/projects/<team>/agent_applications/<id|slug>/ archive POST /api/projects/<team>/agent_applications/<id|slug>/set_env/ bulk replace env GET /api/projects/<team>/agent_applications/<id|slug>/env_keys/ list set keys GET /api/projects/<team>/agent_applications/<id|slug>/env_keys/<KEY>/ is one key set? PUT /api/projects/<team>/agent_applications/<id|slug>/env_keys/<KEY>/ set one key DELETE /api/projects/<team>/agent_applications/<id|slug>/env_keys/<KEY>/ clear one key
Required API key scopes
agents:writePath parameters
- idstring
Request parameters
- namestring
- slugstring
- descriptionstring
- archivedboolean
Response
Example request
PATCH /api /projects /:project_id /agent_applications /:idExample response
Status 200
Delete agent applications
Agent applications — the deployable unit of the platform.
URLs: GET /api/projects/<team>/agent_applications/ list POST /api/projects/<team>/agent_applications/ create GET /api/projects/<team>/agent_applications/<id|slug>/ retrieve PATCH /api/projects/<team>/agent_applications/<id|slug>/ update DELETE /api/projects/<team>/agent_applications/<id|slug>/ archive POST /api/projects/<team>/agent_applications/<id|slug>/set_env/ bulk replace env GET /api/projects/<team>/agent_applications/<id|slug>/env_keys/ list set keys GET /api/projects/<team>/agent_applications/<id|slug>/env_keys/<KEY>/ is one key set? PUT /api/projects/<team>/agent_applications/<id|slug>/env_keys/<KEY>/ set one key DELETE /api/projects/<team>/agent_applications/<id|slug>/env_keys/<KEY>/ clear one key
Required API key scopes
agents:writePath parameters
- idstring
Example request
DELETE /api /projects /:project_id /agent_applications /:idExample response
Status 204 No response body
List all agent applications approvals
List approval-gated tool requests for this application. Team-admin
only (per plan §6.1). Default returns all states — pass ?state=queued
for the inbox view.
Required API key scopes
agents:readPath parameters
- idstring
Query parameters
- limitinteger
- offsetinteger
- statestring
Response
Example request
GET /api /projects /:project_id /agent_applications /:id /approvalsExample response
Status 200
Retrieve agent applications approvals
Single approval request — full proposed args, assistant snapshot, decision metadata, dispatch outcome. Team-admin only (plan §6.1).
Required API key scopes
agents:readPath parameters
- approval_idstring
- idstring
Example request
GET /api /projects /:project_id /agent_applications /:id /approvals /:approval_idExample response
Status 200 No response body
Create agent applications approvals
Approve or reject a queued agent-type tool-approval request.
This is the OWNER decision surface — the only PostHog-authoritative one:
team admins decide here, in the console. principal-type approvals are
decided by the session principal at the ingress decision API, not here.
The runtime side runs the tool platform-side on approve and wakes the
session with a synthetic tool_result either way.
Required API key scopes
agents:writePath parameters
- approval_idstring
- idstring
Request parameters
- decision
- edited_argsobject
- reasonstring
Response
Example request
POST /api /projects /:project_id /agent_applications /:id /approvals /:approval_id /decideExample response
Status 200
Create agent applications
Start a new session on this agent's LIVE (promoted) revision.
Bridges to ingress POST /agents/<slug>/run, forwarding the caller's PAT
so the session principal is the real caller. Returns the new session_id;
drive the conversation with agent-applications-send and read progress with
agent-applications-listen. For non-live / draft revisions use preview_proxy instead.
Required API key scopes
agents:writePath parameters
- idstring
Request parameters
- messagestring
- external_keystring
Response
Example request
POST /api /projects /:project_id /agent_applications /:id /invokeExample response
Status 200
List all agent applications
Poll a LIVE session's progress as a single JSON digest (non-streaming,
MCP-friendly). Bridges to the internal ingress digest RPC — the digest is
built node-side (never in Python). Tenancy is enforced by the team-scoped
get_object() here plus the ingress digest's application_id re-scope;
there is no janitor pre-check on this polled path (see the comment below).
Required API key scopes
agents:readPath parameters
- idstring
Query parameters
- cursorinteger
- max_charsinteger
- session_idstring
Response
Example request
GET /api /projects /:project_id /agent_applications /:id /listenExample response
Status 200
Retrieve agent applications preview proxy
GET passthrough for the preview-proxy — used for /listen SSE.
Required API key scopes
agents:readPath parameters
- idstring
- reststring
Query parameters
- formatstringOne of:
"json""sse" - revision_idstring
Response
Example request
GET /api /projects /:project_id /agent_applications /:id /preview-proxy /:restExample response
Status 200
Create agent applications preview
Authoring-side proxy for invoking a draft (or any non-live) revision.
Closes the anonymous-draft-invoke gap: the public ingress URL refuses
non-live invokes that don't carry the x-agent-preview-secret header;
this proxy attaches it after authenticating the Django caller.
URL: /api/projects/<team>/agent_applications/<app>/preview-proxy/<rest>
Auth: standard PAT / session — agents:write scope (POST run/send/cancel
is a mutating invoke; the read-only listen GET is agents:read).
Required API key scopes
agents:writePath parameters
- idstring
- reststring
Query parameters
- formatstringOne of:
"json""sse" - revision_idstring
Request parameters
- messagestring
- session_idstring
Example request
POST /api /projects /:project_id /agent_applications /:id /preview-proxy /:restExample response
Status 200
Retrieve agent applications preview
GET sibling of preview_token_mint. Same body and response
shape — exists because EventSource can't set headers, so SSE
callers fetch the token via GET and then attach ?preview_token=
to the ingress URL. Behind the same URL (url_path="preview-token")
thanks to DRF's @<action>.mapping.get; DRF resolves it to a
distinct view.action, but it is in scope_object_write_actions
alongside the POST sibling — both return a usable credential, so
both require agents:write.
Required API key scopes
agents:writePath parameters
- idstring
Query parameters
- revision_idstring
Response
Example request
GET /api /projects /:project_id /agent_applications /:id /preview-tokenExample response
Status 200
Create agent applications preview token
Mint a short-lived JWT for talking to a non-live revision
directly via the public ingress URL. The caller attaches it as
the x-agent-preview-token header (or ?preview_token= query
param for EventSource). See _mint_preview_jwt for the
payload + claim binding.
The response also includes endpoints, auth, and
preview_proxy blocks so the caller can wire a preview
invocation without grepping the agent-ingress source for which
path each trigger exposes or which header name carries the
token. This is the "self-describing" half of preview-mode —
every piece of info you need to hit ingress is in one response.
POST is the canonical verb — minting credentials for downstream
run/send/cancel is a write-class capability. A GET sibling
exists at the same URL for EventSource callers (which can't set
headers); it is also write-scoped, since it returns the same token.
Required API key scopes
agents:writePath parameters
- idstring
Query parameters
- revision_idstring
Response
Example request
POST /api /projects /:project_id /agent_applications /:id /preview-tokenExample response
Status 200
Create agent applications
Append a message to an existing LIVE session and re-queue it.
Bridges to ingress POST /agents/<slug>/send, forwarding the caller's PAT
so the ACL principal-match passes. A completed session is NOT terminal —
it's a per-turn idle state for a multi-turn agent, so send re-queues it for
another turn; only truly-terminal states (failed / cancelled / closed) 410,
which passes through as a 410. A janitor ownership pre-check runs first, but
it's redundant defense-in-depth (ingress /send already app-scopes the
load), kept for a clean early 404.
Required API key scopes
agents:writePath parameters
- idstring
Request parameters
- session_idstring
- messagestring
Response
Example request
POST /api /projects /:project_id /agent_applications /:id /sendExample response
Status 200
List all agent applications sessions
List sessions for this application, most recently active first. Strips the
conversation transcript from each summary, but includes a preview
(last assistant text, ~120 chars) and usage_total (token + cost
aggregate). Use agent-applications-sessions-retrieve for the full
transcript of a single session.
Required API key scopes
agents:readPath parameters
- idstring
Query parameters
- created_afterstring
- created_beforestring
- limitinteger
- offsetinteger
- revision_idstring
- statestring
Response
Example request
GET /api /projects /:project_id /agent_applications /:id /sessionsExample response
Status 200
Retrieve agent applications sessions
Fetch one session's state — full conversation by default, or just
the trailing N messages with ?last_n=. Always returns a
usage_total block aggregated over the entire session, regardless of
trim. The runner-side queue DB is the source of truth.
Required API key scopes
agents:readPath parameters
- idstring
- session_idstring
Query parameters
- last_ninteger
Response
Example request
GET /api /projects /:project_id /agent_applications /:id /sessions /:session_idExample response
Status 200
Retrieve agent applications session
Read the runner's structured event log for one session from
ClickHouse. Filters (limit / after / before / level / search)
match the shared LogEntryMixin helper used by hog_function +
hog_flow.
Required API key scopes
agents:readPath parameters
- idstring
- session_idstring
Query parameters
- afterstring
- beforestring
- instance_idstring
- levelstring
- limitintegerDefault:
50 - searchstring
Response
Example request
GET /api /projects /:project_id /agent_applications /:id /sessions /:session_id /logsExample response
Status 200
Retrieve agent applications
Roll-up stats for the agent — drives the agent-detail overview tiles.
Required API key scopes
agents:readPath parameters
- idstring
Query parameters
- sincestring
Response
Example request
GET /api /projects /:project_id /agent_applications /:id /stats