Contexts
Delete messages or the entire context
Send a body with ids to soft-delete specific messages (creates a new version, prior versions retain the messages). Send no body OR {"permanent": true} to permanently delete the entire context (irreversible).
DELETE
/
contexts
/
{id}
TypeScript
// Delete entire context (permanent, irreversible)
await uc.delete('ctx_abc123', { permanent: true })
// Delete messages by id (soft, versioned)
const { data, version } = await uc.delete('ctx_abc123', 'msg_xyz')
// Delete by index (0 = first, -1 = last)
const { data, version } = await uc.delete('ctx_abc123', 0)
// With audit metadata
const { data, version } = await uc.delete('ctx_abc123', 'msg_xyz', {
metadata: { reason: 'hallucination', ticket: 'JIRA-123' }
})
// Multiple deletes (mix of ids and indices)
await uc.delete('ctx_abc123', ['msg_aaa', 0, -1])# Delete entire context (permanent, irreversible)
uc.delete('ctx_abc123', permanent=True)
# Delete messages by id (soft, versioned)
result = uc.delete('ctx_abc123', 'msg_xyz')
# Delete by index (0 = first, -1 = last)
result = uc.delete('ctx_abc123', 0)
# With audit metadata
result = uc.delete('ctx_abc123', 'msg_xyz',
metadata={'reason': 'hallucination', 'ticket': 'JIRA-123'}
)
# Multiple deletes (mix of ids and indices)
uc.delete('ctx_abc123', ['msg_aaa', 0, -1])# Delete entire context (permanent)
curl -X DELETE https://api.ultracontext.ai/contexts/ctx_abc123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"permanent": true}'
# Delete messages by id (soft, versioned)
curl -X DELETE https://api.ultracontext.ai/contexts/ctx_abc123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"ids": "msg_xyz"}'
# Delete by index
curl -X DELETE https://api.ultracontext.ai/contexts/ctx_abc123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"ids": 0}'
# With audit metadata
curl -X DELETE https://api.ultracontext.ai/contexts/ctx_abc123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"ids": [0, "msg_xyz"], "metadata": {"reason": "cleanup"}}'const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({ids: '<string>', metadata: {}})
};
fetch('https://api.ultracontext.ai/contexts/{id}', 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.ultracontext.ai/contexts/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'ids' => '<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://api.ultracontext.ai/contexts/{id}"
payload := strings.NewReader("{\n \"ids\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("DELETE", 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.delete("https://api.ultracontext.ai/contexts/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ids\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ultracontext.ai/contexts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ids\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"deleted": true,
"id": "<string>",
"metadata": {}
}{
"error": "<string>"
}{
"error": "<string>"
}Send
{"ids": [...]} to delete specific messages (soft, versioned). Send {"permanent": true} to delete the entire context (hard, irreversible).Include
metadata to record why this deletion was made. Optional, but recommended for audit trail.Body
application/json
Optional. Omit to delete the entire context. Include ids to delete specific messages.
- Option 1
- Option 2
Either ids (soft-delete specific messages, versioned) or {permanent: true} (hard-delete entire context, irreversible). Any other body shape returns 400 to prevent typos from silently wiping a context.
⌘I
TypeScript
// Delete entire context (permanent, irreversible)
await uc.delete('ctx_abc123', { permanent: true })
// Delete messages by id (soft, versioned)
const { data, version } = await uc.delete('ctx_abc123', 'msg_xyz')
// Delete by index (0 = first, -1 = last)
const { data, version } = await uc.delete('ctx_abc123', 0)
// With audit metadata
const { data, version } = await uc.delete('ctx_abc123', 'msg_xyz', {
metadata: { reason: 'hallucination', ticket: 'JIRA-123' }
})
// Multiple deletes (mix of ids and indices)
await uc.delete('ctx_abc123', ['msg_aaa', 0, -1])# Delete entire context (permanent, irreversible)
uc.delete('ctx_abc123', permanent=True)
# Delete messages by id (soft, versioned)
result = uc.delete('ctx_abc123', 'msg_xyz')
# Delete by index (0 = first, -1 = last)
result = uc.delete('ctx_abc123', 0)
# With audit metadata
result = uc.delete('ctx_abc123', 'msg_xyz',
metadata={'reason': 'hallucination', 'ticket': 'JIRA-123'}
)
# Multiple deletes (mix of ids and indices)
uc.delete('ctx_abc123', ['msg_aaa', 0, -1])# Delete entire context (permanent)
curl -X DELETE https://api.ultracontext.ai/contexts/ctx_abc123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"permanent": true}'
# Delete messages by id (soft, versioned)
curl -X DELETE https://api.ultracontext.ai/contexts/ctx_abc123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"ids": "msg_xyz"}'
# Delete by index
curl -X DELETE https://api.ultracontext.ai/contexts/ctx_abc123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"ids": 0}'
# With audit metadata
curl -X DELETE https://api.ultracontext.ai/contexts/ctx_abc123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"ids": [0, "msg_xyz"], "metadata": {"reason": "cleanup"}}'const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({ids: '<string>', metadata: {}})
};
fetch('https://api.ultracontext.ai/contexts/{id}', 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.ultracontext.ai/contexts/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'ids' => '<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://api.ultracontext.ai/contexts/{id}"
payload := strings.NewReader("{\n \"ids\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("DELETE", 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.delete("https://api.ultracontext.ai/contexts/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ids\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ultracontext.ai/contexts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ids\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"deleted": true,
"id": "<string>",
"metadata": {}
}{
"error": "<string>"
}{
"error": "<string>"
}