会話変数を更新
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": "現在の注文コンテキスト",
"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": "現在の注文コンテキスト",
"created_at": 1787788800,
"updated_at": 1787788980
}承認
すべてのリクエストは API キーで認証します:Authorization: Bearer {API_KEY}。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。
キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP 401(unauthorized)で失敗します。
パスパラメータ
ボディ
application/json
エンドユーザーの識別子。アプリ側で定義し、アプリ内で一意にします。会話の作成時に使った user と一致する必要があります。エンドユーザーの識別 を参照してください。
Required string length:
1 - 255新しい値です。null、文字列、数値、真偽値、オブジェクト、配列のいずれかで、変数の宣言された型と一致する必要があります。
レスポンス
更新後の変数です。
会話変数の ID です。
変数名です。
宣言された型です。string、number、boolean、secret、object、file、none、または array[string]、array[number]、array[object]、array[file]、array[boolean]、array[any] などの配列型です。
文字列型の変数はそのまま返ります。それ以外の型は正規化された JSON 文字列として返り、none は null として返ります。
変数の説明です。
作成時刻(Unix タイムスタンプ、秒)です。
最終更新時刻(Unix タイムスタンプ、秒)です。