cURL
curl --request POST \
--url https://api.langtail.com/v2/threads/{threadId} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"metadata": {
"user_id": "user_123",
"conversation_topic": "product_inquiry",
"priority": "high"
}
}
'import requests
url = "https://api.langtail.com/v2/threads/{threadId}"
payload = { "metadata": {
"user_id": "user_123",
"conversation_topic": "product_inquiry",
"priority": "high"
} }
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
metadata: {user_id: 'user_123', conversation_topic: 'product_inquiry', priority: 'high'}
})
};
fetch('https://api.langtail.com/v2/threads/{threadId}', 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.langtail.com/v2/threads/{threadId}",
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([
'metadata' => [
'user_id' => 'user_123',
'conversation_topic' => 'product_inquiry',
'priority' => 'high'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.langtail.com/v2/threads/{threadId}"
payload := strings.NewReader("{\n \"metadata\": {\n \"user_id\": \"user_123\",\n \"conversation_topic\": \"product_inquiry\",\n \"priority\": \"high\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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.langtail.com/v2/threads/{threadId}")
.header("X-API-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"user_id\": \"user_123\",\n \"conversation_topic\": \"product_inquiry\",\n \"priority\": \"high\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langtail.com/v2/threads/{threadId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadata\": {\n \"user_id\": \"user_123\",\n \"conversation_topic\": \"product_inquiry\",\n \"priority\": \"high\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"createdAt": 123,
"projectId": "<string>",
"metadata": {
"user_id": "user_123",
"conversation_topic": "product_inquiry",
"priority": "high"
},
"createLog": {
"id": "<string>",
"url": "<string>",
"stream": true,
"metadata": "<string>",
"promptId": "<string>",
"threadId": "<string>",
"assistant": true,
"projectId": "<string>",
"requestIP": "<string>",
"startedAt": "2023-11-07T05:31:56Z",
"variables": "<string>",
"parameters": "<string>",
"promptSlug": "<string>",
"doNotRecord": true,
"environment": "<string>",
"openAIKeyId": "<string>",
"projectSlug": "<string>",
"requestData": "<string>",
"deploymentId": "<string>",
"organizationId": "<string>",
"projectAPIKeyId": "<string>",
"organizationSlug": "<string>",
"deploymentVersion": "<string>",
"promptHistoryHash": "<string>",
"openAIOrganization": "<string>"
}
}{
"error": {
"message": "Metadata is required"
}
}{
"error": {
"message": "Thread not found"
}
}Threads
Update a Thread by ID
Updates a thread’s metadata by its ID.
POST
/
v2
/
threads
/
{threadId}
cURL
curl --request POST \
--url https://api.langtail.com/v2/threads/{threadId} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"metadata": {
"user_id": "user_123",
"conversation_topic": "product_inquiry",
"priority": "high"
}
}
'import requests
url = "https://api.langtail.com/v2/threads/{threadId}"
payload = { "metadata": {
"user_id": "user_123",
"conversation_topic": "product_inquiry",
"priority": "high"
} }
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
metadata: {user_id: 'user_123', conversation_topic: 'product_inquiry', priority: 'high'}
})
};
fetch('https://api.langtail.com/v2/threads/{threadId}', 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.langtail.com/v2/threads/{threadId}",
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([
'metadata' => [
'user_id' => 'user_123',
'conversation_topic' => 'product_inquiry',
'priority' => 'high'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.langtail.com/v2/threads/{threadId}"
payload := strings.NewReader("{\n \"metadata\": {\n \"user_id\": \"user_123\",\n \"conversation_topic\": \"product_inquiry\",\n \"priority\": \"high\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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.langtail.com/v2/threads/{threadId}")
.header("X-API-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"user_id\": \"user_123\",\n \"conversation_topic\": \"product_inquiry\",\n \"priority\": \"high\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langtail.com/v2/threads/{threadId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadata\": {\n \"user_id\": \"user_123\",\n \"conversation_topic\": \"product_inquiry\",\n \"priority\": \"high\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"createdAt": 123,
"projectId": "<string>",
"metadata": {
"user_id": "user_123",
"conversation_topic": "product_inquiry",
"priority": "high"
},
"createLog": {
"id": "<string>",
"url": "<string>",
"stream": true,
"metadata": "<string>",
"promptId": "<string>",
"threadId": "<string>",
"assistant": true,
"projectId": "<string>",
"requestIP": "<string>",
"startedAt": "2023-11-07T05:31:56Z",
"variables": "<string>",
"parameters": "<string>",
"promptSlug": "<string>",
"doNotRecord": true,
"environment": "<string>",
"openAIKeyId": "<string>",
"projectSlug": "<string>",
"requestData": "<string>",
"deploymentId": "<string>",
"organizationId": "<string>",
"projectAPIKeyId": "<string>",
"organizationSlug": "<string>",
"deploymentVersion": "<string>",
"promptHistoryHash": "<string>",
"openAIOrganization": "<string>"
}
}{
"error": {
"message": "Metadata is required"
}
}{
"error": {
"message": "Thread not found"
}
}This endpoint allows you to update the metadata of a thread by its unique identifier. Metadata is a key-value storage system that developers can use to store useful information associated with a thread.
Metadata Usage
Metadata can be used to store various types of information related to the thread, such as:- User information (e.g., user ID, name, preferences)
- Conversation context (e.g., topic, category, priority)
- Custom flags or tags
- Timestamps for specific events
- Any other relevant data for your application
Headers
Your Langtail API Key
Example:
"<LANGTAIL_API_KEY>"
Path Parameters
The ID of the thread to update.
Body
application/json
A set of key-value pairs that can be attached to the thread. This can be used to store additional information about the thread to facilitate filtering or organization. Note that the new metadata provided will completely overwrite any existing metadata for the thread.
Example:
{
"user_id": "user_123",
"conversation_topic": "product_inquiry",
"priority": "high"
}
Response
Successfully updated thread
The unique identifier for the thread.
The Unix timestamp (in seconds) of when the thread was created.
The ID of the project this thread belongs to.
The updated set of key-value pairs attached to the thread.
Example:
{
"user_id": "user_123",
"conversation_topic": "product_inquiry",
"priority": "high"
}
A log created by the first message that creates the thread.
Show child attributes
Show child attributes
Was this page helpful?
⌘I