会話を削除
curl --request DELETE \
--url https://{deployed_api_base_url}/v2/conversations/{conversation_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"user": "customer-001"
}
'import requests
url = "https://{deployed_api_base_url}/v2/conversations/{conversation_id}"
payload = { "user": "customer-001" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({user: 'customer-001'})
};
fetch('https://{deployed_api_base_url}/v2/conversations/{conversation_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}",
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([
'user' => 'customer-001'
]),
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}"
payload := strings.NewReader("{\n \"user\": \"customer-001\"\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://{deployed_api_base_url}/v2/conversations/{conversation_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"user\": \"customer-001\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{deployed_api_base_url}/v2/conversations/{conversation_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 \"user\": \"customer-001\"\n}"
response = http.request(request)
puts response.read_bodyデプロイ環境
会話を削除
対象アプリ:Chatflow。
指定した user が所有する会話を削除します。
会話は、会話やメッセージの取得結果に表示されなくなります。メッセージと会話変数は保存されたまま残りますが、API からは読み取れません。同じ会話をもう一度削除すると 404 が返ります。
標準 API の対応する操作:会話を削除。相違点は次のとおりです。
userが必須です。- エラーコードが異なります。
DELETE
/
v2
/
conversations
/
{conversation_id}
会話を削除
curl --request DELETE \
--url https://{deployed_api_base_url}/v2/conversations/{conversation_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"user": "customer-001"
}
'import requests
url = "https://{deployed_api_base_url}/v2/conversations/{conversation_id}"
payload = { "user": "customer-001" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({user: 'customer-001'})
};
fetch('https://{deployed_api_base_url}/v2/conversations/{conversation_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}",
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([
'user' => 'customer-001'
]),
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}"
payload := strings.NewReader("{\n \"user\": \"customer-001\"\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://{deployed_api_base_url}/v2/conversations/{conversation_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"user\": \"customer-001\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{deployed_api_base_url}/v2/conversations/{conversation_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 \"user\": \"customer-001\"\n}"
response = http.request(request)
puts response.read_body承認
すべてのリクエストは API キーで認証します:Authorization: Bearer {API_KEY}。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。
キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP 401(unauthorized)で失敗します。
ボディ
application/json
エンドユーザーの識別子。アプリ側で定義し、アプリ内で一意にします。会話の作成時に使った user と一致する必要があります。エンドユーザーの識別 を参照してください。
Required string length:
1 - 255レスポンス
会話を削除しました。