Publishes a draft agent as a new version
curl --request POST \
--url https://api.langdock.com/agent/v1/publish \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>"
}
'import requests
url = "https://api.langdock.com/agent/v1/publish"
payload = {
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>"
}
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({agentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a', description: '<string>'})
};
fetch('https://api.langdock.com/agent/v1/publish', 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/agent/v1/publish",
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([
'agentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'description' => '<string>'
]),
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/agent/v1/publish"
payload := strings.NewReader("{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"description\": \"<string>\"\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/agent/v1/publish")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/agent/v1/publish")
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 \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "<string>",
"message": "<string>",
"version": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123,
"createdAt": "2023-11-07T05:31:56Z"
}
}Agents API
Agent Veröffentlichen API
Veröffentliche einen Agenten-Entwurf als neue Version
POST
/
agent
/
v1
/
publish
Publishes a draft agent as a new version
curl --request POST \
--url https://api.langdock.com/agent/v1/publish \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>"
}
'import requests
url = "https://api.langdock.com/agent/v1/publish"
payload = {
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>"
}
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({agentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a', description: '<string>'})
};
fetch('https://api.langdock.com/agent/v1/publish', 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/agent/v1/publish",
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([
'agentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'description' => '<string>'
]),
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/agent/v1/publish"
payload := strings.NewReader("{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"description\": \"<string>\"\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/agent/v1/publish")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/agent/v1/publish")
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 \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "<string>",
"message": "<string>",
"version": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123,
"createdAt": "2023-11-07T05:31:56Z"
}
}Veröffentlicht den aktuellen Entwurf eines Agenten als neue Version. Dies entspricht dem Update-Button im Agenten-Editor: Eine veröffentlichte Version ist ein eingefrorener Snapshot des Entwurfs und wird zur aktiven Version, die Workspace-Mitglieder sehen.
Bevor du startest
- Veraltete Assistants API: Dies ist die neue Agents API mit nativer Vercel AI SDK Kompatibilität. Wenn du die veraltete Assistants API verwendest, siehe den Migrations-Guide.
Basis-URL
https://api.langdock.com/agent/v1/publish
Dedicated DeploymentsErsetze
api.langdock.com durch <your-deployment-url>/api/public in allen Anfragen.Entwurf vs. veröffentlichte Version
Änderungen über/agent/v1/update wirken sich nur auf den Entwurf aus. Bis du publish aufrufst, sind diese Änderungen für Workspace-Mitglieder nicht sichtbar.
Anwendungsfälle
- Entwurfsänderungen über die Update-API in eine neue aktive Version überführen
- Änderungen programmatisch ausrollen als Teil einer CI/CD-Pipeline
- Neue Revision veröffentlichen mit optionaler Änderungsbeschreibung in der Versionshistorie
Parameter
| Parameter | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
agentId | string | Ja | UUID des zu veröffentlichenden Agenten |
description | string | Nein | Kurze Änderungsbeschreibung in der Versionshistorie (max. 100 Zeichen) |
Beispiel
const axios = require("axios");
async function publishAgent(agentId, description) {
const response = await axios.post(
"https://api.langdock.com/agent/v1/publish",
{
agentId: agentId,
description: description,
},
{
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
},
);
console.log("Veröffentlichte Version:", response.data.version);
}
publishAgent(
"550e8400-e29b-41d4-a716-446655440000",
"System-Prompt geschärft",
);
Antwort-Format
Erfolgreiche Antwort (200 OK)
{
status: "success";
message: "Agent published successfully";
version: {
id: string; // UUID der neuen Version
version: number; // Monoton steigende Versionsnummer
createdAt: string; // ISO 8601 Zeitstempel
};
}
Validierungsregeln
- Agenten-Zugriff — Der API-Schlüssel muss
owner- odereditor-Zugriff auf den Agenten haben (wie bei Update). - Workspace-Übereinstimmung — Der Agent muss zum selben Workspace gehören wie der API-Schlüssel.
- Nur Agenten — Projekte (
type=PROJECT) werden nicht unterstützt und liefern403. - Entwurfsänderungen erforderlich — Der Entwurf muss sich von der zuletzt veröffentlichten Version unterscheiden. Ein Aufruf ohne ausstehende Änderungen liefert
409 Conflictund spiegelt damit den deaktivierten “Update”-Button in der UI wider.
Fehlerbehandlung
| Status-Code | Beschreibung |
|---|---|
| 400 | Ungültiger Request-Body (fehlende/ungültige agentId oder description zu lang) |
| 401 | Ungültiger oder fehlender API-Schlüssel |
| 403 | API-Schlüssel hat keinen Editier-Zugriff, Agent in anderem Workspace oder ist ein Projekt |
| 409 | Keine Entwurfsänderungen zum Veröffentlichen |
| 429 | Rate Limit überschritten |
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"
Body
application/json
War diese Seite hilfreich?