Close Trace
curl --request POST \
--url https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close \
--header 'X-API-KEY: <api-key>'import requests
url = "https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close"
headers = {"X-API-KEY": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-KEY': '<api-key>'}};
fetch('https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close', 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.promptlayer.com/api/public/v2/traces/{trace_id}/close",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-KEY", "<api-key>")
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.promptlayer.com/api/public/v2/traces/{trace_id}/close")
.header("X-API-KEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"closure": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"workspace_id": 1,
"trace_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"status": "closed",
"created_at": "2026-06-06T18:00:00Z",
"updated_at": "2026-06-06T18:00:00Z"
}
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"success": false,
"message": "Trace already closed"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"success": false,
"message": "<string>",
"error": "<string>"
}Tracking
Close Trace
Marks a trace as closed, preventing any further span ingestion for that trace. Once closed, subsequent calls to /spans-bulk or /v1/traces that include spans for this trace will have those spans rejected.
POST
/
api
/
public
/
v2
/
traces
/
{trace_id}
/
close
Close Trace
curl --request POST \
--url https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close \
--header 'X-API-KEY: <api-key>'import requests
url = "https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close"
headers = {"X-API-KEY": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-KEY': '<api-key>'}};
fetch('https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close', 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.promptlayer.com/api/public/v2/traces/{trace_id}/close",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-KEY", "<api-key>")
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.promptlayer.com/api/public/v2/traces/{trace_id}/close")
.header("X-API-KEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.promptlayer.com/api/public/v2/traces/{trace_id}/close")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"closure": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"workspace_id": 1,
"trace_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"status": "closed",
"created_at": "2026-06-06T18:00:00Z",
"updated_at": "2026-06-06T18:00:00Z"
}
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"success": false,
"message": "Trace already closed"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"success": false,
"message": "<string>",
"error": "<string>"
}Marks a trace as closed, preventing any further spans from being written to it. Once closed, subsequent calls to Create Spans Bulk or Ingest Traces (OTLP) that include spans for this trace will have those spans rejected.
Behavior Notes
- Closing is permanent — there is no re-open operation.
- If the trace is already closed, the endpoint returns
409 Conflict. - If no spans exist for the given
trace_idin your workspace, the endpoint returns404 Not Found.
Related
Was this page helpful?

