ソースを更新
ソースの名前、ステータス、URI、メタデータ、またはプロバイダーパラメータを更新します。設定が変更された場合は、同期を開始することもできます。
name、status、uri、metadata、providerParameters のうち少なくとも 1 つを送信してください。expectedVersion と syncAfterUpdate だけのリクエストは拒否されます。
同期の開始と追跡の方法については、ソースの同期とスケジュール設定 を参照してください。
curl --request PATCH \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expectedVersion": 7,
"name": "Docs site (v2)",
"status": "active",
"syncAfterUpdate": true,
"uri": "https://docs.example.com/v2"
}
'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}"
payload = {
"expectedVersion": 7,
"name": "Docs site (v2)",
"status": "active",
"syncAfterUpdate": True,
"uri": "https://docs.example.com/v2"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expectedVersion: 7,
name: 'Docs site (v2)',
status: 'active',
syncAfterUpdate: true,
uri: 'https://docs.example.com/v2'
})
};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_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://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'expectedVersion' => 7,
'name' => 'Docs site (v2)',
'status' => 'active',
'syncAfterUpdate' => true,
'uri' => 'https://docs.example.com/v2'
]),
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_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}"
payload := strings.NewReader("{\n \"expectedVersion\": 7,\n \"name\": \"Docs site (v2)\",\n \"status\": \"active\",\n \"syncAfterUpdate\": true,\n \"uri\": \"https://docs.example.com/v2\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expectedVersion\": 7,\n \"name\": \"Docs site (v2)\",\n \"status\": \"active\",\n \"syncAfterUpdate\": true,\n \"uri\": \"https://docs.example.com/v2\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expectedVersion\": 7,\n \"name\": \"Docs site (v2)\",\n \"status\": \"active\",\n \"syncAfterUpdate\": true,\n \"uri\": \"https://docs.example.com/v2\"\n}"
response = http.request(request)
puts response.read_body{
"connection_id": "c3d4e5f6-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
"created_at": "2026-09-01T08:00:00Z",
"credential_configured": null,
"id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_synced_at": null,
"metadata": {
"client_request_id": "source-20260907-0001",
"parameters": {
"url": "https://docs.example.com/v2"
},
"providerKind": "website",
"tenantId": "2f1e0d9c-8b7a-4695-8473-2a1b0c9d8e7f"
},
"name": "Docs site (v2)",
"permission_scope": [],
"status": "active",
"sync_policy": null,
"sync_workflow": {
"canceled_at": null,
"checkpoint": "queued",
"completed_at": null,
"created_at": "2026-09-06T02:00:00Z",
"cursor": null,
"execution_attempts": 0,
"failure": null,
"id": "d4c3b2a1-6f5e-4d7c-8b9a-0f1e2d3c4b5a",
"kind": "sync",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_error_code": null,
"max_execution_attempts": 5,
"progress_completed": 0,
"progress_failed": 0,
"progress_skipped": 0,
"progress_total": null,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"state": "queued",
"updated_at": "2026-09-06T02:00:00Z"
},
"type": "web",
"updated_at": "2026-09-06T02:00:00Z",
"uri": "https://docs.example.com/v2",
"version": 8
}Authorizations
すべてのリクエストは、Authorization: Bearer {API_KEY} ヘッダーに指定した API キーで認証します。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。
キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーがない、または無効な場合は HTTP 401(unauthorized)が返ります。
Body
nullable と記されたオプションフィールドでは、null は省略と同じ扱いになります。
正規化後のリクエストは、UTF-8 で 262,144 バイト以内に収める必要があります。リクエストサイズの制限 を参照してください。
- メタデータを更新
- ソース名を変更
- プロバイダーパラメータを更新
- ステータスを変更
- ソース URL を変更
null でない metadata、name、providerParameters、status、uri のうち、少なくとも 1 つを指定してください。expectedVersion と syncAfterUpdate だけでは更新になりません。
選択したデータソースが定義するパラメータです。保存されている metadata.parameters オブジェクト全体が置き換えられるため、残したい値はすべて含めてください。値にはブール値、有限の数値、文字列を使用できます。認証情報のようなキーは拒否されます。
ソースを取得 で機密でないパラメータがすべて公開されておらず、データソースのパラメータ仕様も把握していない場合は、代わりに Dify でソースを設定してください。
true の場合、書き込み後に同期の実行をリクエストします。レスポンスには実行が sync_workflow として含まれます。この呼び出しで実行が開始されなかった場合は sync_workflow: null になります。
同期が開始されるのは、この呼び出しで uri、providerParameters、または metadata の値が変わり、かつソースの status が disabled でない場合だけです。現在と同じ値を再送信しても、同期は開始されません。ソースを変更せずに同期するには、ソースを同期 を呼び出してください。
ページリストが保存されているウェブサイトソースでは、同期によってそれらのページが更新されます。リストを変更するには、ウェブサイトのページをインポート または 選択したページをインポート を使用します。
Response
更新されたソースです。
直近に完了した同期(completed または zero_results)またはインポートの完了日時です。ソース一覧を取得 でのみ設定されます。それ以外の操作、およびソースが一度も同期されていない場合は null です。
active、syncing、error、disabled のいずれかです。ほとんどの操作は保存されている値を返します。ソース一覧を取得 は、直近の同期の実行から値を導き出します:
failedまたはcanceledの実行:errorcompletedまたはzero_resultsの実行:active- 進行中の実行:
syncing
disabled が上書きされることはありません。
Was this page helpful?
curl --request PATCH \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expectedVersion": 7,
"name": "Docs site (v2)",
"status": "active",
"syncAfterUpdate": true,
"uri": "https://docs.example.com/v2"
}
'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}"
payload = {
"expectedVersion": 7,
"name": "Docs site (v2)",
"status": "active",
"syncAfterUpdate": True,
"uri": "https://docs.example.com/v2"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expectedVersion: 7,
name: 'Docs site (v2)',
status: 'active',
syncAfterUpdate: true,
uri: 'https://docs.example.com/v2'
})
};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_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://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'expectedVersion' => 7,
'name' => 'Docs site (v2)',
'status' => 'active',
'syncAfterUpdate' => true,
'uri' => 'https://docs.example.com/v2'
]),
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_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}"
payload := strings.NewReader("{\n \"expectedVersion\": 7,\n \"name\": \"Docs site (v2)\",\n \"status\": \"active\",\n \"syncAfterUpdate\": true,\n \"uri\": \"https://docs.example.com/v2\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expectedVersion\": 7,\n \"name\": \"Docs site (v2)\",\n \"status\": \"active\",\n \"syncAfterUpdate\": true,\n \"uri\": \"https://docs.example.com/v2\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expectedVersion\": 7,\n \"name\": \"Docs site (v2)\",\n \"status\": \"active\",\n \"syncAfterUpdate\": true,\n \"uri\": \"https://docs.example.com/v2\"\n}"
response = http.request(request)
puts response.read_body{
"connection_id": "c3d4e5f6-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
"created_at": "2026-09-01T08:00:00Z",
"credential_configured": null,
"id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_synced_at": null,
"metadata": {
"client_request_id": "source-20260907-0001",
"parameters": {
"url": "https://docs.example.com/v2"
},
"providerKind": "website",
"tenantId": "2f1e0d9c-8b7a-4695-8473-2a1b0c9d8e7f"
},
"name": "Docs site (v2)",
"permission_scope": [],
"status": "active",
"sync_policy": null,
"sync_workflow": {
"canceled_at": null,
"checkpoint": "queued",
"completed_at": null,
"created_at": "2026-09-06T02:00:00Z",
"cursor": null,
"execution_attempts": 0,
"failure": null,
"id": "d4c3b2a1-6f5e-4d7c-8b9a-0f1e2d3c4b5a",
"kind": "sync",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_error_code": null,
"max_execution_attempts": 5,
"progress_completed": 0,
"progress_failed": 0,
"progress_skipped": 0,
"progress_total": null,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"state": "queued",
"updated_at": "2026-09-06T02:00:00Z"
},
"type": "web",
"updated_at": "2026-09-06T02:00:00Z",
"uri": "https://docs.example.com/v2",
"version": 8
}