Base URL
Authentication
All API requests require an API key passed as thex-api-key header.
Invoke an Expert
POST/api/agents/invoke
Send a message to an expert and receive a response. Supports streaming (default) and async job modes.
Request Body
* Use either
agent or agents, never both.
Fields
async and wait_for_completion are not supported — use stream only.Attachments
Each entry in theattachments array is an object with the following fields:
No other fields are accepted — extra keys return 400. Maximum 20 attachments per invoke.
JSON request body example with attachments:
Get a presigned upload URL
Call this endpoint once per file before invoking with attachments. POST/api/agents/invoke/attachments/upload-url
Request fields:
Response fields:
Streaming Mode (Default)
Whenstream is omitted or true, the response is a Server-Sent Events (SSE) stream at HTTP 200 with Content-Type: text/event-stream.
Lines beginning with data: are JSON payloads. Lines beginning with : keepalive are heartbeat comments — ignore them when parsing.
Streaming responses include an X-Request-Id response header containing the server-generated request correlation ID.
Event sequence
1.meta — always the first event
chunk — zero or more token events
done — terminal success
Single agent:
request_id echoed in meta, done, async 202, poll responses, and the X-Request-Id response header. Save it to look up the LangSmith trace timeline (see Traces).
Example
Async Mode (stream: false)
When stream is false, the server returns 202 Accepted immediately with a task_id you can poll.
Step 1 — Create the async task
Step 2 — Poll for the result
status_url to get the full polling URL.
Possible status values: queued, running, completed, failed, timeout, canceled
Step 3 — Cancel (optional)
Cancel anyqueued or running task (including a streaming run, using its task_id from meta):
cancel_applied: false and a reason field:
Other statuses:
Thread Continuity
thread_token keeps messages connected into a single conversation thread.
Multi-turn example
Multi-Agent Collaboration
Use theagents array (not agent) to orchestrate multiple experts in a single turn.
- The
doneevent and poll responses includeagents_used(display names of agents that contributed), notagents. - Keep the same
agentsroster andthread_tokenon follow-ups for continuity.
Delivery Options
Deliver to a Google Chat Space
Deliver as DM from the agent
Delivery diagnostics
Streamingdone events may include delivery_error (string) when posting to the configured destination failed, or delivered_to (object) confirming where the result was sent. Polled GET task-status responses do NOT carry a separate delivery_error field on success — use streaming if you need delivery diagnostics in the HTTP body.
Read Endpoints
Task status
GET/api/agents/invoke/{task_id}
Retrieve status and output for any invocation (streaming or async) by task_id. The task_id is returned in the streaming meta event and in the async 202 response.
Invocation history
GET/api/invocations
Response shape:
{ "invocations": [...] } — each item includes task_id, status, thread_token, mode, input, output, and timestamps.
Traces and Debugging
Every invoke turn returns a UUIDrequest_id (in meta/done, the async 202 body, poll responses, and the X-Request-Id response header). Use it to fetch the LangSmith trace timeline for that turn. Same x-api-key as invoke; you must have hired the expert.
GET /api/agents/{agent_id}/traces/{request_id}/timeline
Returns run header fields (name, status, start_time, end_time, error) and an interleaved timeline of model and tool events. When truncated is true, the trace exceeded internal fetch limits.
LangSmith indexing can lag a few seconds after invoke completes — retry if you get 404 immediately after
done.Error Responses
Windows PowerShell
Usecurl.exe — PowerShell’s built-in curl is an alias for Invoke-WebRequest and is not compatible.
Best Practices
- Start with streaming mode (
-Nflag) and parse the initialmetaevent before anychunklines. - Move to async mode only when your system needs job-style polling.
- Keep agent IDs lowercase with hyphens.
- Add
contextfor better, more relevant answers. - Save
task_idfor traceability andthread_tokenfor conversation continuity. - On multi-turn flows, always send the current
thread_token, not a stale one from a prior segment.
Next Steps
Managing API Keys
Create and manage your API keys.
Triggers
Automate expert invocations on a schedule.