TypeScript
const ctx = await uc.create()
// With metadata
const ctx = await uc.create({ metadata: { name: 'my-session' } })
// Copy from existing (latest version)
const fork = await uc.create({ from: 'ctx_abc123' })
// Fork from specific version
const v1Fork = await uc.create({ from: 'ctx_abc123', version: 1 })
// Fork at specific message index
const partial = await uc.create({ from: 'ctx_abc123', at: 5 })
// Fork from point-in-time
const snapshot = await uc.create({ from: 'ctx_abc123', before: '2024-01-15T10:30:00Z' })ctx = uc.create()
# With metadata
ctx = uc.create(metadata={'name': 'my-session'})
# Copy from existing (latest version)
fork = uc.create(from_='ctx_abc123')
# Fork from specific version
v1_fork = uc.create(from_='ctx_abc123', version=1)
# Fork at specific message index
partial = uc.create(from_='ctx_abc123', at=5)
# Fork from point-in-time
snapshot = uc.create(from_='ctx_abc123', before='2024-01-15T10:30:00Z')curl -X POST https://api.ultracontext.ai/contexts \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"metadata": {"name": "my-session"}}'
# Fork from specific version
curl -X POST https://api.ultracontext.ai/contexts \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"from": "ctx_abc123", "version": 1}'
# Fork from point-in-time
curl -X POST https://api.ultracontext.ai/contexts \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"from": "ctx_abc123", "before": "2024-01-15T10:30:00Z"}'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '<string>',
version: 123,
at: 123,
before: '2023-11-07T05:31:56Z',
metadata: {}
})
};
fetch('https://api.ultracontext.ai/contexts', 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",
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([
'from' => '<string>',
'version' => 123,
'at' => 123,
'before' => '2023-11-07T05:31:56Z',
'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"
payload := strings.NewReader("{\n \"from\": \"<string>\",\n \"version\": 123,\n \"at\": 123,\n \"before\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {}\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.ultracontext.ai/contexts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"<string>\",\n \"version\": 123,\n \"at\": 123,\n \"before\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ultracontext.ai/contexts")
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 \"from\": \"<string>\",\n \"version\": 123,\n \"at\": 123,\n \"before\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "ctx_a1b2c3d4e5f6",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Contexts
Create context
Create a new context. Optionally copy from an existing context using the from parameter, and specify a version to fork from a specific version.
POST
/
contexts
TypeScript
const ctx = await uc.create()
// With metadata
const ctx = await uc.create({ metadata: { name: 'my-session' } })
// Copy from existing (latest version)
const fork = await uc.create({ from: 'ctx_abc123' })
// Fork from specific version
const v1Fork = await uc.create({ from: 'ctx_abc123', version: 1 })
// Fork at specific message index
const partial = await uc.create({ from: 'ctx_abc123', at: 5 })
// Fork from point-in-time
const snapshot = await uc.create({ from: 'ctx_abc123', before: '2024-01-15T10:30:00Z' })ctx = uc.create()
# With metadata
ctx = uc.create(metadata={'name': 'my-session'})
# Copy from existing (latest version)
fork = uc.create(from_='ctx_abc123')
# Fork from specific version
v1_fork = uc.create(from_='ctx_abc123', version=1)
# Fork at specific message index
partial = uc.create(from_='ctx_abc123', at=5)
# Fork from point-in-time
snapshot = uc.create(from_='ctx_abc123', before='2024-01-15T10:30:00Z')curl -X POST https://api.ultracontext.ai/contexts \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"metadata": {"name": "my-session"}}'
# Fork from specific version
curl -X POST https://api.ultracontext.ai/contexts \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"from": "ctx_abc123", "version": 1}'
# Fork from point-in-time
curl -X POST https://api.ultracontext.ai/contexts \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"from": "ctx_abc123", "before": "2024-01-15T10:30:00Z"}'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '<string>',
version: 123,
at: 123,
before: '2023-11-07T05:31:56Z',
metadata: {}
})
};
fetch('https://api.ultracontext.ai/contexts', 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",
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([
'from' => '<string>',
'version' => 123,
'at' => 123,
'before' => '2023-11-07T05:31:56Z',
'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"
payload := strings.NewReader("{\n \"from\": \"<string>\",\n \"version\": 123,\n \"at\": 123,\n \"before\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {}\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.ultracontext.ai/contexts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"<string>\",\n \"version\": 123,\n \"at\": 123,\n \"before\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ultracontext.ai/contexts")
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 \"from\": \"<string>\",\n \"version\": 123,\n \"at\": 123,\n \"before\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "ctx_a1b2c3d4e5f6",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Use
from with version, at, or before to fork from a specific point in history. Learn more in the Fork & Clone Contexts guide.Authorizations
API key from your UltraContext dashboard
Body
application/json
Create a new context with optional fork params and metadata
Source context ID to copy from (optional)
When forking with from, copy from this specific version (0-indexed)
When forking with from, copy only messages 0 through this index
When forking with from, copy point-in-time state before this ISO timestamp
User-defined metadata for this context
⌘I