更新会话变量
curl --request PUT \
--url https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"user": "customer-001",
"value": {
"order_id": "ORDER-1001",
"priority": false
}
}
'import requests
url = "https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}"
payload = {
"user": "customer-001",
"value": {
"order_id": "ORDER-1001",
"priority": False
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({user: 'customer-001', value: {order_id: 'ORDER-1001', priority: false}})
};
fetch('https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_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://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'user' => 'customer-001',
'value' => [
'order_id' => 'ORDER-1001',
'priority' => false
]
]),
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://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}"
payload := strings.NewReader("{\n \"user\": \"customer-001\",\n \"value\": {\n \"order_id\": \"ORDER-1001\",\n \"priority\": false\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"user\": \"customer-001\",\n \"value\": {\n \"order_id\": \"ORDER-1001\",\n \"priority\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user\": \"customer-001\",\n \"value\": {\n \"order_id\": \"ORDER-1001\",\n \"priority\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "6fa459ea-ee8a-3ca4-894e-db77e160355e",
"name": "order_context",
"value_type": "object",
"value": "{\"order_id\":\"ORDER-1001\",\"priority\":false}",
"description": "Current order context",
"created_at": 1787788800,
"updated_at": 1787788980
}部署环境
更新会话变量
PUT
/
v2
/
conversations
/
{conversation_id}
/
variables
/
{variable_id}
更新会话变量
curl --request PUT \
--url https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"user": "customer-001",
"value": {
"order_id": "ORDER-1001",
"priority": false
}
}
'import requests
url = "https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}"
payload = {
"user": "customer-001",
"value": {
"order_id": "ORDER-1001",
"priority": False
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({user: 'customer-001', value: {order_id: 'ORDER-1001', priority: false}})
};
fetch('https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_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://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'user' => 'customer-001',
'value' => [
'order_id' => 'ORDER-1001',
'priority' => false
]
]),
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://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}"
payload := strings.NewReader("{\n \"user\": \"customer-001\",\n \"value\": {\n \"order_id\": \"ORDER-1001\",\n \"priority\": false\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"user\": \"customer-001\",\n \"value\": {\n \"order_id\": \"ORDER-1001\",\n \"priority\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{deployed_api_base_url}/v2/conversations/{conversation_id}/variables/{variable_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user\": \"customer-001\",\n \"value\": {\n \"order_id\": \"ORDER-1001\",\n \"priority\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "6fa459ea-ee8a-3ca4-894e-db77e160355e",
"name": "order_context",
"value_type": "object",
"value": "{\"order_id\":\"ORDER-1001\",\"priority\":false}",
"description": "Current order context",
"created_at": 1787788800,
"updated_at": 1787788980
}授权
路径参数
请求体
application/json
响应
更新后的变量。
会话变量 ID。
变量名称。
声明的类型:string、number、boolean、secret、object、file、none,或数组类型,例如 array[string]、array[number]、array[object]、array[file]、array[boolean]、array[any]。
String variables come back as-is; other types come back as a canonical JSON string; none comes back as null.
变量描述。
创建时间,Unix 时间戳(秒)。
最后更新时间,Unix 时间戳(秒)。