Developer Platform: Namespaced APIs, Real-time Events, and Tool Tracing
A comprehensive guide to Anakin's namespaced developer APIs, Server-Sent Events (SSE) live conversation feeds, and D1 tool execution tracing logs.
Developer Platform: Namespaced APIs, Real-time Events, and Tool Tracing
Anakin's Developer Platform exposes enterprise-grade infrastructure to build, trace, and monitor autonomous AI digital workers programmatically. This guide walks through the API namespace separation, real-time event streaming, tool execution tracing, and webhook notification system.
1. Namespaced API Architecture
The Developer API is partitioned into two distinct namespaces to optimize service pathways and decouple live agent operations from CRUD metadata configurations.
Deprecation & Backwards Compatibility
All direct legacy paths (e.g. /api/v1/agents/) remain active as alias endpoints for backwards compatibility. When invoked, these endpoints route context to the new namespaced handlers and attach an RFC-compliant HTTP Warning: 299 response header:
``http
Warning: 299 - "This endpoint is deprecated. Please use namespaced paths (/api/v1/runtime/... or /api/v1/data/...)"
`
A. Runtime API Namespace (/api/v1/runtime/)
Handles live, low-latency execution flows and streaming events:
- POST /api/v1/runtime/agents/:id/chat
- Interactive chat with an agent (supports SSE streams and JSON payloads). - POST /api/v1/runtime/agents/:id/workflows/:workflowId/run
- Trigger workflow runs programmatically. - GET /api/v1/runtime/conversations/:conversationId/events
- Stream live conversation frame deltas. - GET /api/v1/runtime/runs/:runId
- Retrieve tool trace logs.
B. Data API Namespace (/api/v1/data/*)
Handles static configurations, metadata management, and visitor databases:
- GET /api/v1/data/agents
- List all owned agents. - POST /api/v1/data/agents
- Create a new agent. - GET /api/v1/data/agents/:id
- Retrieve details of a specific agent. - PATCH /api/v1/data/agents/:id
- Update settings, behavior instructions, or greetings of an agent. - DELETE /api/v1/data/agents/:id
- Delete an agent. - GET /api/v1/data/agents/:id/bookings
- Retrieve visitor bookings. - GET /api/v1/data/agents/:id/orders
- Retrieve e-commerce orders. - GET /api/v1/data/agents/:id/form-submissions
- Retrieve custom form responses.
2. Real-Time Conversation Event Streams (SSE)
For live monitoring dashboards, supervisor panels, or customer support takeovers, you can hook into a real-time event feed of an active session.
The SSE Endpoint
`http
GET /api/v1/runtime/conversations/:conversationId/events
Authorization: Bearer ak_live_...
`
This establishes a Server-Sent Events (SSE) connection directly to the Durable Object connection pool handling the active session. Any message generated, tool call initiated, or result returned is pushed down the pipe in real time:
`json
data: {"type": "text-delta", "textDelta": "Calculating total quarterly revenue..."}
data: {"type": "tool-call", "toolCallId": "direct-1-runSQL", "toolName": "runSQL", "args": {"query": "SELECT SUM(amount) FROM sales;"}}
data: {"type": "tool-result", "toolCallId": "direct-1-runSQL", "toolName": "runSQL", "result": {"sum": 45390.50}}
`
3. Run Tracing & Tool Latency Analytics
Every AI agent request or dynamic workflow run translates into a structured plan composed of multiple steps (LLM decisions, direct tools, tool execution results, and summaries). Anakin tracks, measures, and records every step trace into edge D1 tables:
Querying Trace Logs
`http
GET /api/v1/runtime/runs/:runId
Authorization: Bearer ak_live_...
`
#### Example Response payload:
`json
{
"id": "run-8e3c7a21-4b12-98bc-a383-e7fec812",
"agent_id": "669336a7-872f-4f1b-b2c1-4bd5121a185f",
"status": "success",
"total_latency_ms": 1420,
"steps": [
{
"id": "step-2a14902b-a178-4ef3-a3d1-44bb77cf18ff",
"step_type": "tool",
"step_name": "web_search",
"latency_ms": 320,
"error": null
},
{
"id": "step-924a73fe-d54b-449e-b2d9-11cbf7a8e2cc",
"step_type": "llm",
"step_name": "step-1-execute",
"latency_ms": 1100,
"error": null
}
]
}
`
4. Webhook Dispatch System
Anakin triggers automated POST webhooks once asynchronous operations conclude.
Webhook Event List
- agent.message.completed
: Fired when an agent chat stream ends. Payload contains the final compiled reply and user query. - workflow.completed
: Fired when a durable workflow run finishes. Includes astatusfield (successorfailed) representing the execution outcome. - lead.captured
: Fired when a new lead is captured. - booking.created
: Fired when a new appointment is booked. - order.created
: Fired when a new e-commerce order is placed. - form.submitted`: Fired when a custom form is submitted.