Python SDK
import httpx
# Send a batch of trace payloads (each follows the POST /api/v1/traces shape).
resp = httpx.post(
"https://api.decimal.ai/api/v1/traces/batch",
headers={"Authorization": "Bearer dai_sk_..."},
json=[trace_payload_1, trace_payload_2],
timeout=60.0,
)
resp.raise_for_status()
print(resp.json()["count"], "ingested")curl --request POST \
--url https://api.decimal.ai/api/v1/traces/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '[
{}
]'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([{}])
};
fetch('https://api.decimal.ai/api/v1/traces/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://api.decimal.ai/api/v1/traces/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([
[
]
]),
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://api.decimal.ai/api/v1/traces/batch"
payload := strings.NewReader("[\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://api.decimal.ai/api/v1/traces/batch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {}\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.decimal.ai/api/v1/traces/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 {}\n]"
response = http.request(request)
puts response.read_body{
"status": "ok",
"count": 2,
"trace_ids": [
"trc_001",
"trc_002"
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}traces
Ingest a batch of traces
Ingest a batch of traces in a single request.
Each payload follows the same shape as POST /api/v1/traces. Per-trace
failures are returned in the errors field — partial success is allowed.
POST
/
api
/
v1
/
traces
/
batch
Python SDK
import httpx
# Send a batch of trace payloads (each follows the POST /api/v1/traces shape).
resp = httpx.post(
"https://api.decimal.ai/api/v1/traces/batch",
headers={"Authorization": "Bearer dai_sk_..."},
json=[trace_payload_1, trace_payload_2],
timeout=60.0,
)
resp.raise_for_status()
print(resp.json()["count"], "ingested")curl --request POST \
--url https://api.decimal.ai/api/v1/traces/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '[
{}
]'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([{}])
};
fetch('https://api.decimal.ai/api/v1/traces/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://api.decimal.ai/api/v1/traces/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([
[
]
]),
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://api.decimal.ai/api/v1/traces/batch"
payload := strings.NewReader("[\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://api.decimal.ai/api/v1/traces/batch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {}\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.decimal.ai/api/v1/traces/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 {}\n]"
response = http.request(request)
puts response.read_body{
"status": "ok",
"count": 2,
"trace_ids": [
"trc_001",
"trc_002"
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}⌘I