Skip to main content
PATCH
/
agent
/
v1
/
update
Updates an existing agent
curl --request PATCH \
  --url https://api.langdock.com/agent/v1/update \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "name": "<string>",
  "instructions": "<string>",
  "description": "<string>",
  "temperature": 0.5,
  "model": "<string>",
  "capabilities": {
    "webSearch": true,
    "dataAnalyst": true,
    "imageGeneration": true
  },
  "actions": [
    "<unknown>"
  ],
  "vectorDb": [
    "<unknown>"
  ],
  "knowledgeFolderIds": [
    "<string>"
  ],
  "attachmentIds": [
    "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  ]
}
'
⚠️ Using our API via a dedicated deployment? Just replace api.langdock.com with your deployment’s base URL: <deployment-url>/api/public
This is the new Agents API with native Vercel AI SDK compatibility. If you’re using the legacy Assistants API, see the migration guide.
Updates an existing agent in your workspace. Only the fields you provide will be updated, allowing for partial updates without affecting other configuration.
Requires an API key with the AGENT_API scope and access to the agent you want to update.

Update Behavior

The update endpoint uses partial update semantics with specific behavior for different field types:
  • Partial updates - Only fields provided in the request are updated; omitted fields remain unchanged
  • Array fields replace - actions, inputFields, conversationStarters, and attachments completely replace existing values when provided
  • Empty arrays - Send [] to remove all actions/fields/attachments
  • Null handling - Send null for emoji to clear it. For description and instruction, send an empty string "" to clear them
  • Unchanged fields - Fields not included in the request retain their current values

Request Parameters

All fields are optional except agentId:
ParameterTypeRequiredDescription
agentIdstringYesUUID of the agent to update
namestringNoUpdated name (1-80 characters)
descriptionstringNoUpdated description (max 500 chars, "" to clear)
emojistringNoUpdated emoji icon (max 16 chars, null to clear)
instructionstringNoUpdated system prompt (max 40000 chars, "" to clear)
modelstringNoUpdated model identifier (deployment name from the Models API)
creativitynumberNoUpdated temperature between 0-1
conversationStartersstring[]NoUpdated array of suggested prompts (replaces existing, max 20, each 1-255 chars)
actionsarrayNoUpdated array of actions (replaces existing)
inputFieldsarrayNoUpdated array of form fields (replaces existing)
attachmentsstring[]NoUpdated array of attachment UUIDs (replaces existing)
webSearchbooleanNoUpdated web search capability setting
imageGenerationbooleanNoUpdated image generation capability setting
dataAnalystbooleanNoUpdated code interpreter capability setting
inputTypestringNoInput type: “PROMPT” or “STRUCTURED”
canvasbooleanNoUpdated canvas capability setting
Array fields (actions, inputFields, conversationStarters, attachments) are replaced entirely, not merged. Always provide the complete desired array, including any existing items you want to keep.

Actions Configuration

Each action in the actions array should contain:
  • actionId (required) - UUID of the action from an enabled integration
  • requiresConfirmation (optional) - Whether to require user confirmation before executing (default: true)

Input Fields Configuration

For inputFields array structure, see the Create Agent API documentation.

Examples

Updating Basic Properties

const axios = require("axios");

async function updateAgentName() {
  const response = await axios.patch(
    "https://api.langdock.com/agent/v1/update",
    {
      agentId: "550e8400-e29b-41d4-a716-446655440000",
      name: "Advanced Document Analyzer",
      description: "Analyzes documents with enhanced capabilities",
      creativity: 0.7
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

  console.log("Agent updated:", response.data.message);
}

Validation Rules

The API enforces several validation rules:
  • Agent access - Your API key must have access to the agent
  • Workspace match - Agent must belong to the same workspace as your API key
  • Model - If provided, must be in your workspace’s active models list
  • Actions - If provided, must belong to integrations enabled in your workspace
  • Attachments - If provided, must exist in your workspace and not be deleted
  • Name - If provided, must be between 1-80 characters
  • Description - If provided, maximum 500 characters
  • Instruction - If provided, maximum 40000 characters
  • Creativity - If provided, must be between 0 and 1

Response Format

Success Response (200 OK)

{
  status: "success";
  message: "Agent updated successfully";
  agent: {
    id: string;
    name: string;
    description: string;
    instruction: string;
    emojiIcon: string;
    model: string;
    temperature: number;
    conversationStarters: string[];
    inputType: "PROMPT" | "STRUCTURED";
    webSearchEnabled: boolean;
    imageGenerationEnabled: boolean;
    codeInterpreterEnabled: boolean;
    canvasEnabled: boolean;
    actions: Array<{
      actionId: string;
      requiresConfirmation: boolean;
    }>;
    inputFields: Array<{
      type: string;
      label: string;
      description: string;
      required: boolean;
      order: number;
    }>;
    attachments: string[];
    createdAt: string;
    updatedAt: string;
  };
}

Error Handling

try {
  const response = await axios.patch('https://api.langdock.com/agent/v1/update', ...);
} catch (error) {
  if (error.response) {
    switch (error.response.status) {
      case 400:
        console.error('Invalid parameters or resource not found:', error.response.data.message);
        break;
      case 401:
        console.error('Invalid or missing API key');
        break;
      case 403:
        console.error('Insufficient permissions - no access to this agent');
        break;
      case 404:
        console.error('Agent not found or API key does not have access');
        break;
      case 429:
        console.error('Rate limit exceeded');
        break;
      case 500:
        console.error('Server error');
        break;
    }
  }
}

Best Practices

Preserving existing values: When updating array fields like actions or attachments, always include existing items you want to keep, as the entire array is replaced.
  1. Fetch before update - If you need to preserve existing array values, fetch the current agent configuration first
  2. Incremental updates - Update only the fields that need to change
  3. Validate attachments - Ensure attachment UUIDs are valid before including them
  4. Test actions - Verify actions belong to enabled integrations before updating
  5. Handle errors gracefully - Implement proper error handling for validation failures
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

Authorization
string
header
required

API key as Bearer token. Format "Bearer YOUR_API_KEY"

Body

application/json
agentId
string<uuid>
required
name
string
required
Maximum string length: 64
instructions
string
required
Maximum string length: 16384
description
string
Maximum string length: 256
temperature
number
Required range: 0 <= x <= 1
model
string
Maximum string length: 64
capabilities
object
actions
any[]
vectorDb
any[]
knowledgeFolderIds
string[]
attachmentIds
string<uuid>[]

Array of UUID strings identifying attachments for this message

Response

200

Agent updated successfully