Skip to main content
POST
/
api
/
v1
/
analytics
/
batch
Create Batch Analytics
curl --request POST \
  --url https://control-plane.kubiya.ai/api/v1/analytics/batch \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "execution_id": "<string>",
  "turns": [
    {
      "execution_id": "<string>",
      "turn_number": 123,
      "model": "<string>",
      "started_at": "<string>",
      "turn_id": "<string>",
      "model_provider": "<string>",
      "completed_at": "<string>",
      "duration_ms": 123,
      "input_tokens": 0,
      "output_tokens": 0,
      "cache_read_tokens": 0,
      "cache_creation_tokens": 0,
      "total_tokens": 0,
      "input_cost": 0,
      "output_cost": 0,
      "cache_read_cost": 0,
      "cache_creation_cost": 0,
      "total_cost": 0,
      "finish_reason": "<string>",
      "response_preview": "<string>",
      "tools_called_count": 0,
      "tools_called_names": [
        "<string>"
      ],
      "error_message": "<string>",
      "metrics": {},
      "runtime_minutes": 0,
      "model_weight": 1,
      "tool_calls_weight": 1,
      "aem_value": 0,
      "aem_cost": 0
    }
  ],
  "tool_calls": [
    {
      "execution_id": "<string>",
      "tool_name": "<string>",
      "started_at": "<string>",
      "turn_id": "<string>",
      "tool_use_id": "<string>",
      "completed_at": "<string>",
      "duration_ms": 123,
      "tool_input": {},
      "tool_output": "<string>",
      "tool_output_size": 123,
      "success": true,
      "error_message": "<string>",
      "error_type": "<string>",
      "metadata": {}
    }
  ],
  "tasks": [
    {
      "execution_id": "<string>",
      "task_description": "<string>",
      "task_number": 123,
      "task_id": "<string>",
      "task_type": "<string>",
      "status": "pending",
      "started_at": "<string>",
      "completed_at": "<string>",
      "duration_ms": 123,
      "result": "<string>",
      "error_message": "<string>",
      "metadata": {}
    }
  ]
}
'
import requests

url = "https://control-plane.kubiya.ai/api/v1/analytics/batch"

payload = {
"execution_id": "<string>",
"turns": [
{
"execution_id": "<string>",
"turn_number": 123,
"model": "<string>",
"started_at": "<string>",
"turn_id": "<string>",
"model_provider": "<string>",
"completed_at": "<string>",
"duration_ms": 123,
"input_tokens": 0,
"output_tokens": 0,
"cache_read_tokens": 0,
"cache_creation_tokens": 0,
"total_tokens": 0,
"input_cost": 0,
"output_cost": 0,
"cache_read_cost": 0,
"cache_creation_cost": 0,
"total_cost": 0,
"finish_reason": "<string>",
"response_preview": "<string>",
"tools_called_count": 0,
"tools_called_names": ["<string>"],
"error_message": "<string>",
"metrics": {},
"runtime_minutes": 0,
"model_weight": 1,
"tool_calls_weight": 1,
"aem_value": 0,
"aem_cost": 0
}
],
"tool_calls": [
{
"execution_id": "<string>",
"tool_name": "<string>",
"started_at": "<string>",
"turn_id": "<string>",
"tool_use_id": "<string>",
"completed_at": "<string>",
"duration_ms": 123,
"tool_input": {},
"tool_output": "<string>",
"tool_output_size": 123,
"success": True,
"error_message": "<string>",
"error_type": "<string>",
"metadata": {}
}
],
"tasks": [
{
"execution_id": "<string>",
"task_description": "<string>",
"task_number": 123,
"task_id": "<string>",
"task_type": "<string>",
"status": "pending",
"started_at": "<string>",
"completed_at": "<string>",
"duration_ms": 123,
"result": "<string>",
"error_message": "<string>",
"metadata": {}
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
execution_id: '<string>',
turns: [
{
execution_id: '<string>',
turn_number: 123,
model: '<string>',
started_at: '<string>',
turn_id: '<string>',
model_provider: '<string>',
completed_at: '<string>',
duration_ms: 123,
input_tokens: 0,
output_tokens: 0,
cache_read_tokens: 0,
cache_creation_tokens: 0,
total_tokens: 0,
input_cost: 0,
output_cost: 0,
cache_read_cost: 0,
cache_creation_cost: 0,
total_cost: 0,
finish_reason: '<string>',
response_preview: '<string>',
tools_called_count: 0,
tools_called_names: ['<string>'],
error_message: '<string>',
metrics: {},
runtime_minutes: 0,
model_weight: 1,
tool_calls_weight: 1,
aem_value: 0,
aem_cost: 0
}
],
tool_calls: [
{
execution_id: '<string>',
tool_name: '<string>',
started_at: '<string>',
turn_id: '<string>',
tool_use_id: '<string>',
completed_at: '<string>',
duration_ms: 123,
tool_input: {},
tool_output: '<string>',
tool_output_size: 123,
success: true,
error_message: '<string>',
error_type: '<string>',
metadata: {}
}
],
tasks: [
{
execution_id: '<string>',
task_description: '<string>',
task_number: 123,
task_id: '<string>',
task_type: '<string>',
status: 'pending',
started_at: '<string>',
completed_at: '<string>',
duration_ms: 123,
result: '<string>',
error_message: '<string>',
metadata: {}
}
]
})
};

fetch('https://control-plane.kubiya.ai/api/v1/analytics/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://control-plane.kubiya.ai/api/v1/analytics/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'execution_id' => '<string>',
'turns' => [
[
'execution_id' => '<string>',
'turn_number' => 123,
'model' => '<string>',
'started_at' => '<string>',
'turn_id' => '<string>',
'model_provider' => '<string>',
'completed_at' => '<string>',
'duration_ms' => 123,
'input_tokens' => 0,
'output_tokens' => 0,
'cache_read_tokens' => 0,
'cache_creation_tokens' => 0,
'total_tokens' => 0,
'input_cost' => 0,
'output_cost' => 0,
'cache_read_cost' => 0,
'cache_creation_cost' => 0,
'total_cost' => 0,
'finish_reason' => '<string>',
'response_preview' => '<string>',
'tools_called_count' => 0,
'tools_called_names' => [
'<string>'
],
'error_message' => '<string>',
'metrics' => [

],
'runtime_minutes' => 0,
'model_weight' => 1,
'tool_calls_weight' => 1,
'aem_value' => 0,
'aem_cost' => 0
]
],
'tool_calls' => [
[
'execution_id' => '<string>',
'tool_name' => '<string>',
'started_at' => '<string>',
'turn_id' => '<string>',
'tool_use_id' => '<string>',
'completed_at' => '<string>',
'duration_ms' => 123,
'tool_input' => [

],
'tool_output' => '<string>',
'tool_output_size' => 123,
'success' => true,
'error_message' => '<string>',
'error_type' => '<string>',
'metadata' => [

]
]
],
'tasks' => [
[
'execution_id' => '<string>',
'task_description' => '<string>',
'task_number' => 123,
'task_id' => '<string>',
'task_type' => '<string>',
'status' => 'pending',
'started_at' => '<string>',
'completed_at' => '<string>',
'duration_ms' => 123,
'result' => '<string>',
'error_message' => '<string>',
'metadata' => [

]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://control-plane.kubiya.ai/api/v1/analytics/batch"

payload := strings.NewReader("{\n \"execution_id\": \"<string>\",\n \"turns\": [\n {\n \"execution_id\": \"<string>\",\n \"turn_number\": 123,\n \"model\": \"<string>\",\n \"started_at\": \"<string>\",\n \"turn_id\": \"<string>\",\n \"model_provider\": \"<string>\",\n \"completed_at\": \"<string>\",\n \"duration_ms\": 123,\n \"input_tokens\": 0,\n \"output_tokens\": 0,\n \"cache_read_tokens\": 0,\n \"cache_creation_tokens\": 0,\n \"total_tokens\": 0,\n \"input_cost\": 0,\n \"output_cost\": 0,\n \"cache_read_cost\": 0,\n \"cache_creation_cost\": 0,\n \"total_cost\": 0,\n \"finish_reason\": \"<string>\",\n \"response_preview\": \"<string>\",\n \"tools_called_count\": 0,\n \"tools_called_names\": [\n \"<string>\"\n ],\n \"error_message\": \"<string>\",\n \"metrics\": {},\n \"runtime_minutes\": 0,\n \"model_weight\": 1,\n \"tool_calls_weight\": 1,\n \"aem_value\": 0,\n \"aem_cost\": 0\n }\n ],\n \"tool_calls\": [\n {\n \"execution_id\": \"<string>\",\n \"tool_name\": \"<string>\",\n \"started_at\": \"<string>\",\n \"turn_id\": \"<string>\",\n \"tool_use_id\": \"<string>\",\n \"completed_at\": \"<string>\",\n \"duration_ms\": 123,\n \"tool_input\": {},\n \"tool_output\": \"<string>\",\n \"tool_output_size\": 123,\n \"success\": true,\n \"error_message\": \"<string>\",\n \"error_type\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"tasks\": [\n {\n \"execution_id\": \"<string>\",\n \"task_description\": \"<string>\",\n \"task_number\": 123,\n \"task_id\": \"<string>\",\n \"task_type\": \"<string>\",\n \"status\": \"pending\",\n \"started_at\": \"<string>\",\n \"completed_at\": \"<string>\",\n \"duration_ms\": 123,\n \"result\": \"<string>\",\n \"error_message\": \"<string>\",\n \"metadata\": {}\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://control-plane.kubiya.ai/api/v1/analytics/batch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"execution_id\": \"<string>\",\n \"turns\": [\n {\n \"execution_id\": \"<string>\",\n \"turn_number\": 123,\n \"model\": \"<string>\",\n \"started_at\": \"<string>\",\n \"turn_id\": \"<string>\",\n \"model_provider\": \"<string>\",\n \"completed_at\": \"<string>\",\n \"duration_ms\": 123,\n \"input_tokens\": 0,\n \"output_tokens\": 0,\n \"cache_read_tokens\": 0,\n \"cache_creation_tokens\": 0,\n \"total_tokens\": 0,\n \"input_cost\": 0,\n \"output_cost\": 0,\n \"cache_read_cost\": 0,\n \"cache_creation_cost\": 0,\n \"total_cost\": 0,\n \"finish_reason\": \"<string>\",\n \"response_preview\": \"<string>\",\n \"tools_called_count\": 0,\n \"tools_called_names\": [\n \"<string>\"\n ],\n \"error_message\": \"<string>\",\n \"metrics\": {},\n \"runtime_minutes\": 0,\n \"model_weight\": 1,\n \"tool_calls_weight\": 1,\n \"aem_value\": 0,\n \"aem_cost\": 0\n }\n ],\n \"tool_calls\": [\n {\n \"execution_id\": \"<string>\",\n \"tool_name\": \"<string>\",\n \"started_at\": \"<string>\",\n \"turn_id\": \"<string>\",\n \"tool_use_id\": \"<string>\",\n \"completed_at\": \"<string>\",\n \"duration_ms\": 123,\n \"tool_input\": {},\n \"tool_output\": \"<string>\",\n \"tool_output_size\": 123,\n \"success\": true,\n \"error_message\": \"<string>\",\n \"error_type\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"tasks\": [\n {\n \"execution_id\": \"<string>\",\n \"task_description\": \"<string>\",\n \"task_number\": 123,\n \"task_id\": \"<string>\",\n \"task_type\": \"<string>\",\n \"status\": \"pending\",\n \"started_at\": \"<string>\",\n \"completed_at\": \"<string>\",\n \"duration_ms\": 123,\n \"result\": \"<string>\",\n \"error_message\": \"<string>\",\n \"metadata\": {}\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://control-plane.kubiya.ai/api/v1/analytics/batch")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"execution_id\": \"<string>\",\n \"turns\": [\n {\n \"execution_id\": \"<string>\",\n \"turn_number\": 123,\n \"model\": \"<string>\",\n \"started_at\": \"<string>\",\n \"turn_id\": \"<string>\",\n \"model_provider\": \"<string>\",\n \"completed_at\": \"<string>\",\n \"duration_ms\": 123,\n \"input_tokens\": 0,\n \"output_tokens\": 0,\n \"cache_read_tokens\": 0,\n \"cache_creation_tokens\": 0,\n \"total_tokens\": 0,\n \"input_cost\": 0,\n \"output_cost\": 0,\n \"cache_read_cost\": 0,\n \"cache_creation_cost\": 0,\n \"total_cost\": 0,\n \"finish_reason\": \"<string>\",\n \"response_preview\": \"<string>\",\n \"tools_called_count\": 0,\n \"tools_called_names\": [\n \"<string>\"\n ],\n \"error_message\": \"<string>\",\n \"metrics\": {},\n \"runtime_minutes\": 0,\n \"model_weight\": 1,\n \"tool_calls_weight\": 1,\n \"aem_value\": 0,\n \"aem_cost\": 0\n }\n ],\n \"tool_calls\": [\n {\n \"execution_id\": \"<string>\",\n \"tool_name\": \"<string>\",\n \"started_at\": \"<string>\",\n \"turn_id\": \"<string>\",\n \"tool_use_id\": \"<string>\",\n \"completed_at\": \"<string>\",\n \"duration_ms\": 123,\n \"tool_input\": {},\n \"tool_output\": \"<string>\",\n \"tool_output_size\": 123,\n \"success\": true,\n \"error_message\": \"<string>\",\n \"error_type\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"tasks\": [\n {\n \"execution_id\": \"<string>\",\n \"task_description\": \"<string>\",\n \"task_number\": 123,\n \"task_id\": \"<string>\",\n \"task_type\": \"<string>\",\n \"status\": \"pending\",\n \"started_at\": \"<string>\",\n \"completed_at\": \"<string>\",\n \"duration_ms\": 123,\n \"result\": \"<string>\",\n \"error_message\": \"<string>\",\n \"metadata\": {}\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>"
    }
  ]
}

Authorizations

Authorization
string
header
required

Enter your Kubiya API token (format: Bearer )

Body

application/json

Schema for batch creating analytics data (used by workers to send all data at once)

execution_id
string
required
turns
TurnMetricsCreate · object[]
tool_calls
ToolCallCreate · object[]
tasks
TaskCreate · object[]

Response

Successful Response