Grant Knowledge base access to people or workspace API keys
curl --request POST \
--url https://api.langdock.com/knowledge/{folderId}/access \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"targetIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
'import requests
url = "https://api.langdock.com/knowledge/{folderId}/access"
payload = { "targetIds": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({targetIds: ['3c90c3cc-0d44-4b50-8888-8dd25736052a']})
};
fetch('https://api.langdock.com/knowledge/{folderId}/access', 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.langdock.com/knowledge/{folderId}/access",
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([
'targetIds' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]),
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.langdock.com/knowledge/{folderId}/access"
payload := strings.NewReader("{\n \"targetIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.langdock.com/knowledge/{folderId}/access")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"targetIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/knowledge/{folderId}/access")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"targetIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}"
response = http.request(request)
puts response.read_bodyKnowledge Folder API
Zugriff auf Wissensdatenbanken teilen
Gewähre, ändere oder entziehe Zugriff auf eine Wissensdatenbank für Personen und Workspace-API-Schlüssel
POST
/
knowledge
/
{folderId}
/
access
Grant Knowledge base access to people or workspace API keys
curl --request POST \
--url https://api.langdock.com/knowledge/{folderId}/access \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"targetIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
'import requests
url = "https://api.langdock.com/knowledge/{folderId}/access"
payload = { "targetIds": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({targetIds: ['3c90c3cc-0d44-4b50-8888-8dd25736052a']})
};
fetch('https://api.langdock.com/knowledge/{folderId}/access', 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.langdock.com/knowledge/{folderId}/access",
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([
'targetIds' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]),
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.langdock.com/knowledge/{folderId}/access"
payload := strings.NewReader("{\n \"targetIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.langdock.com/knowledge/{folderId}/access")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"targetIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/knowledge/{folderId}/access")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"targetIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}"
response = http.request(request)
puts response.read_bodyGewährt, ändert oder entzieht Zugriff auf eine bestehende Wissensdatenbank. Ziele sind Personen und Workspace-API-Schlüssel. Gruppen bleiben im In-App-Teilen.
Ein Schlüssel nur mit Betrachter-Zugriff, auch über die API-Suche der Wissensdatenbank, kann diese Endpoints nicht aufrufen.
Ein Bearbeiter-Workspace-Schlüssel kann andere qualifizierte Workspace-Schlüssel freigeben, auch wenn der Schlüsselbesitzer kein Workspace-Admin ist. Der Teilen-Dialog in der App listet API-Schlüssel weiterhin nur für Workspace-Admins.
Alle IDs müssen zu einem menschlichen Workspace-Mitglied oder einem qualifizierten Workspace-API-Schlüssel gehören. Gruppen-IDs werden nicht akzeptiert. Persönliche API-Schlüssel sind nicht berechtigt. Fehlt eine ID oder ist sie nicht berechtigt, schlägt die Anfrage fehl und es wird nichts geschrieben.
Du kannst den Zugriff des Besitzers nicht ändern. Übertrage die Besitzerschaft zuerst in Dateien. Fehlt noch eine Freigabe, legt diese Anfrage sie an.
Du kannst den Zugriff des Besitzers nicht entziehen.
Bevor du startest
- API-Key-Scope: Erfordert einen API-Schlüssel mit dem
KNOWLEDGE_FOLDER_APIScope. Der API-Schlüssel selbst braucht die Rolle Bearbeiter auf der Wissensdatenbank. Siehe Wissensdatenbanken mit der API teilen für die Einrichtung. - Wissensdatenbanken: Die Knowledge Folder API verwaltet Ressourcen, die in der Library als Wissensdatenbanken erscheinen.
Basis-URL
https://api.langdock.com
Dedicated DeploymentsErsetze
api.langdock.com durch <your-deployment-url>/api/public in allen Anfragen.Rollen
| API-Wert | Label in Dateien | Zugriff |
|---|---|---|
USER | Betrachter | Suchen und Dateien abrufen |
EDITOR | Bearbeiter | Hochladen, aktualisieren, löschen, Zugriff teilen und umbenennen |
Zugriff gewähren
POST /knowledge/{folderId}/access
Pfadparameter
| Parameter | Typ | Pflicht | Beschreibung |
|---|---|---|---|
folderId | string | Ja | Die ID der Wissensdatenbank |
Request Body
| Feld | Typ | Pflicht | Beschreibung |
|---|---|---|---|
targetIds | string[] | Ja | User-IDs und Workspace-API-Schlüssel-IDs. Minimum: 1. Maximum: 100. |
role | string | Ja | USER oder EDITOR |
Gewähren mit cURL
curl -X POST "https://api.langdock.com/knowledge/{folderId}/access" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"targetIds": [
"7c9e6679-7425-40de-944b-e07fc1f90ae7",
"550e8400-e29b-41d4-a716-446655440000"
],
"role": "EDITOR"
}'
Gewähren mit JavaScript
const axios = require("axios");
async function grantAccess(folderId, targetIds, role) {
const response = await axios.post(
`https://api.langdock.com/knowledge/${folderId}/access`,
{ targetIds, role },
{
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
}
);
return response.data;
}
const result = await grantAccess(
"3fa85f64-5717-4562-b3fc-2c963f66afa6",
["7c9e6679-7425-40de-944b-e07fc1f90ae7"],
"EDITOR"
);
console.log(result.result.granted);
Erfolgreiche Antwort (200 OK)
{
"status": "success",
"result": {
"granted": [
{
"type": "USER",
"targetId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"role": "EDITOR"
},
{
"type": "API_KEY",
"targetId": "550e8400-e29b-41d4-a716-446655440000",
"role": "EDITOR"
}
]
}
}
Rolle ändern
PATCH /knowledge/{folderId}/access
| Feld | Typ | Pflicht | Beschreibung |
|---|---|---|---|
type | string | Ja | USER oder API_KEY |
targetId | string | Ja | ID der Person oder des Workspace-Schlüssels |
role | string | Ja | USER oder EDITOR |
curl -X PATCH "https://api.langdock.com/knowledge/{folderId}/access" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "API_KEY",
"targetId": "550e8400-e29b-41d4-a716-446655440000",
"role": "USER"
}'
{
"status": "success"
}
Zugriff entziehen
DELETE /knowledge/{folderId}/access
| Feld | Typ | Pflicht | Beschreibung |
|---|---|---|---|
type | string | Ja | USER oder API_KEY |
targetId | string | Ja | ID der Person oder des Workspace-Schlüssels |
curl -X DELETE "https://api.langdock.com/knowledge/{folderId}/access" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "API_KEY",
"targetId": "550e8400-e29b-41d4-a716-446655440000"
}'
{
"status": "success"
}
Fehlerbehandlung
| Status | Bedeutung |
|---|---|
400 | Ungültiger Body, unzulässiges Ziel oder Änderung am Besitzer |
401 | Ungültiger oder fehlender API-Schlüssel |
403 | Fehlender KNOWLEDGE_FOLDER_API Scope, oder der Schlüssel ist kein Bearbeiter dieser Wissensdatenbank |
404 | Wissensdatenbank oder Zugriffs-Ziel nicht gefunden |
429 | Rate Limit überschritten |
500 | Unerwarteter Serverfehler |
Langdock blockiert bewusst Browser-basierte Anfragen, um deinen API-Schlüssel zu schützen und die Sicherheit deiner Anwendungen zu gewährleisten. Weitere Informationen findest du in unserem Guide zu Best Practices für API-Schlüssel.
Autorisierungen
API key as Bearer token. Format "Bearer YOUR_API_KEY"
Pfadparameter
The ID of the knowledge folder
Body
application/json
Antwort
200
Access granted successfully
War diese Seite hilfreich?