Get Task Logs
https://agent.blackbox.ai/api/v1/tasks/{runId}/logsRetrieve the full execution log for a task as parsed stream events. For live tasks, events come from the in-memory buffer. For completed tasks, events are reconstructed from persisted message parts.
This endpoint returns the complete execution log for a task as an array of parsed events. It automatically selects the best available source — live in-memory buffer for running tasks, or reconstructed events from the database for completed tasks.
Authentication
To use this API, you need a BLACKBOX API Key. Follow these steps to get your API key:
- Go to app.blackbox.ai/agent-api and click Get an API Key (requires a Pro subscription)
- Once provisioning completes, you will be redirected to your Dashboard
- From the Dashboard, create an API key to use with all Agent API requests
Your API key will be in the format: sk-xxxxxxxxxxxxxxxxxxxxxx
Headers
AuthorizationstringrequiredAPI Key of the form Bearer <api_key>.
Example: Bearer sk_b41b647ffbfed27f616560
Path Parameters
runIdstringrequiredThe unique run identifier returned when the task was created.
Example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
Query Parameters
includeDeltasbooleandefault: trueWhether to include text-delta events (individual text chunks). Set to false for a smaller, summarized payload.
Default: true
Example: includeDeltas=false
rawbooleandefault: falseInclude raw SSE lines in the rawEvents field of the response.
Default: false
Example: raw=true
Response Fields
runIdstringThe run identifier.
chatIdstringThe chat thread UUID for this run.
statusstringCurrent external status: queued, running, completed, failed, cancelled, or interrupted.
sourcestringWhere the events came from: "buffer" (live in-memory), "reconstructed" (from DB), or "merged".
eventCountnumberTotal number of events returned.
eventsarrayArray of parsed event objects.
errorstring | nullError message if the run failed, null otherwise.
rawEventsarrayRaw SSE lines (only present when raw=true).
curl 'https://agent.blackbox.ai/api/v1/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890/logs' \
-H 'Authorization: Bearer YOUR_API_KEY'curl 'https://agent.blackbox.ai/api/v1/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890/logs?includeDeltas=false' \
-H 'Authorization: Bearer YOUR_API_KEY'const API_KEY = "YOUR_API_KEY";
const RUN_ID = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
const response = await fetch(
`https://agent.blackbox.ai/api/v1/tasks/${RUN_ID}/logs?includeDeltas=false`,
{ headers: { Authorization: `Bearer ${API_KEY}` } }
);
const data = await response.json();
console.log(`Source: ${data.source}, Events: ${data.eventCount}`);
// Print tool calls
data.events
.filter(e => e.type === "tool-call-start")
.forEach(e => console.log(`Tool: ${e.toolName}`));import requests
API_KEY = "YOUR_API_KEY"
RUN_ID = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
response = requests.get(
f"https://agent.blackbox.ai/api/v1/tasks/{RUN_ID}/logs",
headers={"Authorization": f"Bearer {API_KEY}"},
params={"includeDeltas": "false"},
)
data = response.json()
print(f"Source: {data['source']}, Events: {data['eventCount']}")
for event in data["events"]:
if event["type"] == "tool-call-start":
print(f"Tool called: {event['toolName']}"){
"runId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"chatId": "chat_def789ghi012",
"status": "completed",
"source": "reconstructed",
"eventCount": 5,
"events": [
{
"type": "text-start",
"id": "msg_abc123"
},
{
"type": "tool-call-start",
"toolCallId": "tc_001",
"toolName": "bash"
},
{
"type": "tool-input-available",
"toolCallId": "tc_001",
"toolName": "bash",
"input": { "command": "ls -la /vercel/sandbox" }
},
{
"type": "tool-output-available",
"toolCallId": "tc_001",
"toolName": "bash",
"output": { "stdout": "total 8\ndrwxr-xr-x 2 root root 4096 ...", "exitCode": 0 }
},
{
"type": "finish",
"runId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "completed"
}
],
"error": null
}{
"error": "Task not found"
}Error Codes
| Status Code | Error | Description |
|---|---|---|
| 200 | Success | Logs retrieved successfully |
| 401 | Unauthorized | Invalid or missing API key |
| 403 | Forbidden | Task belongs to a different user |
| 404 | Not Found | Task not found |
| 500 | Internal Server Error | Failed to fetch logs |