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 Publish API
Publish a draft agent as a new 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"
}
}Publishes the current draft of an agent as a new version. This mirrors the Update button in the agent editor: a published version is a frozen snapshot of the draft that becomes the active version users see.
Before You Start
- Legacy Assistants API: This is the new Agents API with native Vercel AI SDK compatibility. If you’re using the legacy Assistants API, see the migration guide.
Base URL
https://api.langdock.com/agent/v1/publish
Dedicated deploymentsReplace
api.langdock.com with <your-deployment-url>/api/public in all requests.Draft vs. Published Version
Edits made via/agent/v1/update only affect the draft. Until you call publish, those changes are not visible to workspace members.
Use Cases
- Promote draft edits made via the Update API into a new active version
- Roll out changes programmatically as part of a CI/CD pipeline
- Release a new revision with an optional change description shown in version history
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
agentId | string | Yes | UUID of the agent to publish |
description | string | No | Short change description shown in version history (max 100 characters) |
Example
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("Published version:", response.data.version);
}
publishAgent(
"550e8400-e29b-41d4-a716-446655440000",
"Tightened the system prompt",
);
Response Format
Success Response (200 OK)
{
status: "success";
message: "Agent published successfully";
version: {
id: string; // UUID of the new version
version: number; // Monotonically increasing version number
createdAt: string; // ISO 8601 timestamp
};
}
Validation Rules
- Agent access — The API key must have
owneroreditoraccess to the agent (same as Update). - Workspace match — The agent must belong to the same workspace as the API key.
- Agents only — Projects (
type=PROJECT) are not supported and will return403. - Has draft changes — The draft must differ from the latest published version. Publishing with no pending changes returns
409 Conflict, mirroring the disabled “Update” button in the UI.
Error Handling
| Status Code | Description |
|---|---|
| 400 | Invalid request body (missing or malformed agentId / description too long) |
| 401 | Invalid or missing API key |
| 403 | API key does not have edit access, the agent is in a different workspace, or the resource is a project |
| 409 | No draft changes to publish |
| 429 | Rate limit exceeded |
Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on API Key Best Practices.
Authorizations
API key as Bearer token. Format "Bearer YOUR_API_KEY"
Body
application/json
Was this page helpful?