Data Analysis API Cookbook
Common data analysis workflows through ResearchX APIs
Data Analysis API Cookbook
This page gives practical recipes for external agents. Examples assume a Bearer token and use {projectId} as the project identifier.
Upload A CSV And Start Analysis
Use this when a caller provides a CSV and wants summaries, plots, and conclusions.
Steps:
- Upload the file to workspace.
- Inspect available agents.
- Create an agent ticket.
- Watch the ticket stream.
- Read the final report.
Upload:
curl -X POST "$BASE_URL/api/projects/{projectId}/agent-workspace" \
-H "Authorization: Bearer $TOKEN" \
-F "file=@./input.csv" \
-F "path=data" \
-F "conflict_policy=overwrite"path is the destination parent directory. The uploaded filename is taken from the file itself, so this request stores input.csv as data/input.csv.
Create a task:
{
"task_type": "data_analysis",
"title": "Analyze uploaded CSV",
"intent_summary": "Inspect data/input.csv, summarize columns, compute descriptive statistics, and write reports/summary.md.",
"priority": "normal",
"conversation_id": "conv_123",
"add_to_conversation": true,
"input": {
"source": "external_api",
"files": ["data/input.csv"],
"expected_outputs": ["reports/summary.md", "reports/figures"]
}
}task_type should come from an available agent definition returned by GET /api/projects/{projectId}/agents; data_analysis is only an example classification. To target a specific installed agent, include its agent_definition_id in input.
If the task card and result should be returned to a conversation, create or select a conversation first and include both conversation_id and add_to_conversation: true.
Success criteria:
- Ticket status is
succeededorpartial_succeeded. - Full ticket detail contains events and artifacts.
- Workspace contains
reports/summary.mdor the requested output paths.
Read A Markdown Result
GET /api/projects/{projectId}/agent-workspace/content?path=reports/summary.mdIf the path is unknown, search first:
GET /api/projects/{projectId}/agent-workspace?query=summary&limit=20Download Plots Or Result Files
GET /api/projects/{projectId}/agent-workspace/download?path=reports/figures/plot.png
GET /api/projects/{projectId}/agent-workspace/download?path=results/result.csvAsk the analysis agent to write stable output paths, for example:
Please save the final report to reports/summary.md and plots to reports/figures/.Handle Permission Requests
Find pending requests:
GET /api/projects/{projectId}/tool-permission-requests?status=pendingPreview changes:
GET /api/projects/{projectId}/tool-permission-requests/{requestId}/diff-previewApprove or deny:
POST /api/projects/{projectId}/tool-permission-requests/{requestId}/approve
POST /api/projects/{projectId}/tool-permission-requests/{requestId}/denyAfter approval, continue watching the original ticket or conversation stream.
Use A Container Environment
Check container status and options:
GET /api/projects/{projectId}/container/status
GET /api/projects/{projectId}/container/optionsEnable and start:
{
"image": "researchx-runtime:latest",
"container_cpu_count": 4,
"container_memory_mb": 8192
}POST /api/projects/{projectId}/container/enable
POST /api/projects/{projectId}/container/startInside the container, write outputs under /workspace/reports or /workspace/results.
Diagnose Failed Tasks
When a ticket fails:
- Fetch
GET /api/projects/{projectId}/agent-tickets/{ticketId}?mode=full. - Inspect
latest_run.failure_codeandlatest_run.failure_message. - Inspect error-level events.
- Check whether artifacts contain partial outputs.
- If containers were involved, inspect container events or build logs.
Retry only when the failure is input, environment, permission, or transient service related.
Add MCP Tools
GET /api/projects/{projectId}/mcp/servers
POST /api/projects/{projectId}/mcp/servers
POST /api/projects/{projectId}/mcp/servers/{serverId}/test
GET /api/projects/{projectId}/mcp/servers/{serverId}/toolsRecommended setup:
- Expose only tools needed for the task.
- Require confirmation for tools that write to external systems.
- Keep
allowed_toolsandconfirmation_toolsexplicit.
Use Chat For Lightweight Analysis
Use project chat for shorter tasks:
POST /api/projects/{projectId}/chatConsume the SSE stream and wait for done before reading conversation messages or workspace outputs. Prefer agent tickets for long-running work, cancellation, artifacts, and reliable status tracking.