Skip to main content
PUT
/
v1
/
agents
/
{agentId}
Update Agent
curl --request PUT \
  --url https://api.talkifai.dev/v1/agents/{agentId} \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "name": "<string>",
  "description": "<string>",
  "sysMsg": "<string>",
  "model": "<string>",
  "stt": "<string>",
  "voiceId": "<string>",
  "realtimeProvider": "openai",
  "greetingType": "agentFirst",
  "greetingMessage": "<string>",
  "lastMessage": "<string>",
  "temperature": 123,
  "inactivityTimeout": 35,
  "mode": "public",
  "languages": [
    "<string>"
  ],
  "functionCallingEnabled": true,
  "enabledFunctions": [
    "<string>"
  ],
  "enabledCustomFunctions": [
    "<string>"
  ]
}
'
{
  "success": true,
  "data": {
    "agent": {
      "id": "5b710eca-ee67-4c3a-aeb6-8b541f451b40",
      "name": "Customer Support Bot",
      "description": "Handles tier-1 support queries",
      "agentArchitecture": "pipeline",
      "model": "gpt_4o_mini",
      "stt": "deepgram",
      "voiceId": "gemini-leda-en",
      "realtimeProvider": "openai",
      "sysMsg": "You are a helpful customer support agent for Acme Corp. Be concise and friendly.",
      "greetingType": "agentFirst",
      "greetingMessage": "Hello! How can I help you today?",
      "temperature": 0.7,
      "inactivityTimeout": 30,
      "lastMessage": "Is there anything else I can help you with?",
      "mode": "public",
      "functionCallingEnabled": false,
      "enabledFunctions": [
        "<string>"
      ],
      "enabledCustomFunctions": [
        "<string>"
      ],
      "languages": [
        {
          "id": "<string>",
          "language": "en"
        }
      ],
      "userId": "<string>",
      "organizationId": "<string>",
      "createdAt": "2023-11-07T05:31:56Z",
      "updatedAt": "2023-11-07T05:31:56Z"
    }
  }
}

Overview

Updates an existing agent’s configuration. Send only the fields you want to modify — all other fields remain unchanged. Authentication: Session-based (Better Auth) Scope: Active organization from session

Request

Path Parameters:
ParameterTypeRequiredDescription
agentIdstringAgent ID (ULID format)
Headers:
Authorization: Bearer YOUR_SESSION_TOKEN
Content-Type: application/json
Request Body:
{
  "name": "Updated Agent Name",
  "description": "Updated description",
  "sysMsg": "Updated system prompt...",
  "languages": ["english", "urdu"],
  "agentArchitecture": "pipeline",
  "model": "gpt_4o_mini",
  "stt": "deepgram",
  "voiceId": "cartesia-voice-456",
  "realtimeProvider": "gemini",
  "greetingType": "agentFirst",
  "greetingMessage": "Hello! How can I assist you?",
  "lastMessage": "Goodbye!",
  "temperature": 0.7,
  "inactivityTimeout": 30,
  "mode": "public"
}
Optional Fields:
FieldTypeValidationDescription
namestring2-50 charsAgent display name
descriptionstringMax 200 charsInternal description
sysMsgstringMax 5000 charsSystem prompt
languagesarray1+ itemsLanguage codes (en, ur, sd)
agentArchitecturestringFixed after createpipeline, realtime, or text
modelstringRequired for pipeline/textLLM model
sttstringRequired for pipelineSTT provider
voiceIdstringRequired for pipelineVoice ID
realtimeProviderstringRequired for realtimeopenai or gemini
greetingTypestringagentFirst or userFirstWho speaks first
greetingMessagestringOptionalGreeting text
lastMessagestringMax 100 charsFarewell message
temperaturenumber0.1–1.0Response randomness
inactivityTimeoutnumber10–60 secondsSilence timeout
modestringpublic, private, commercialVisibility mode

Response

Status: 200 OK
{
  "success": true,
  "agent": {
    "id": "agent_abc123",
    "name": "Updated Agent Name",
    "description": "Updated description",
    "agentArchitecture": "pipeline",
    "mode": "public",
    "model": "gpt_4o_mini",
    "stt": "deepgram",
    "voiceId": "cartesia-voice-456",
    "sysMsg": "Updated system prompt...",
    "functionCallingEnabled": true,
    "enabledFunctions": ["web_search", "end_call"],
    "enabledCustomFunctions": [],
    "greetingType": "agentFirst",
    "greetingMessage": "Hello! How can I assist you?",
    "lastMessage": "Goodbye!",
    "temperature": 0.7,
    "inactivityTimeout": 30,
    "createdAt": "2024-01-10T09:00:00Z",
    "updatedAt": "2024-01-15T14:30:00Z",
    "userId": "user_xyz789",
    "organizationId": "org_123",
    "languages": [
      {
        "id": "lang_123",
        "language": "english"
      },
      {
        "id": "lang_124",
        "language": "urdu"
      }
    ],
    "VoiceOption": {
      "voiceId": "cartesia-voice-456",
      "voiceName": "Sonic British",
      "provider": "cartesia"
    }
  }
}
Special Response (Missing API Keys):
{
  "success": true,
  "agent": { /* ... agent object ... */ },
  "missingKeys": ["openaiKey"],
  "usedDefaults": true,
  "finalModel": "gemini-2.0-flash",
  "finalStt": "gemini",
  "redirectUrl": "/organization?callbackUrl=/agents/create-agent/agent_abc123"
}

Access Control

User RoleCan Update
Owner✅ Any agent in organization
Admin✅ Any agent in organization
Member (Creator)✅ Own agents (except commercial)
Member (Not Creator)❌ Cannot update
Commercial Agent Restriction:
  • Only Owners/Admins can update commercial agents
  • Creators cannot modify their own commercial agents

Validation Rules

Architecture-Specific Validation

Pipeline:
{
  "agentArchitecture": "pipeline",
  "voiceId": "required",
  "model": "required",
  "stt": "required"
}
Realtime:
{
  "agentArchitecture": "realtime",
  "realtimeProvider": "required (openai or gemini)",
  "voiceId": "required if greetingType=agentFirst"
}
Text:
{
  "agentArchitecture": "text",
  "model": "required",
  "voiceId": "not applicable",
  "stt": "not applicable"
}

Field Validation

FieldRuleError Message
inactivityTimeout10–60 seconds”Inactivity timeout must be between 10 and 60 seconds”
modepublic/private/commercial”Invalid agent mode”
languagesen/ur/sd only”Invalid language:
nameRequired”Name is required”
descriptionRequired”Description is required”
sysMsgRequired”System message is required”

Mode Change Validation

Changing to Commercial:
{
  "mode": "commercial"
}
  • ✅ Allowed for Owners/Admins
  • ❌ Forbidden for Members
  • Error: “Only organization owners and admins can set agent as commercial”

Error Responses

401 Unauthorized

{
  "error": "Unauthorized"
}

403 Forbidden

{
  "error": "You don't have permission to update this agent"
}

400 Bad Request

{
  "error": "Inactivity timeout must be between 10 and 60 seconds"
}
{
  "error": "For pipeline architecture, voiceId, model, and STT are required"
}
{
  "error": "Invalid agent mode. Must be 'public', 'private', or 'commercial'"
}

404 Not Found

{
  "error": "Agent not found"
}

500 Server Error

{
  "error": "Update failed"
}

Examples

cURL

curl -X PUT "https://studio.talkifai.dev/api/agents/agent_abc123" \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Support Bot",
    "temperature": 0.5,
    "mode": "public"
  }'

JavaScript (Fetch)

const agentId = "agent_abc123";
const updateData = {
  name: "Updated Support Bot",
  temperature: 0.5,
  mode: "public"
};

const response = await fetch(`/api/agents/${agentId}`, {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${sessionToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(updateData)
});

const data = await response.json();
if (data.redirectUrl) {
  // Missing API keys - redirect to configure
  window.location.href = data.redirectUrl;
}

Next.js (Client Component)

async function updateAgent(agentId: string, updates: Partial<Agent>) {
  const response = await fetch(`/api/agents/${agentId}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(updates)
  });

  const data = await response.json();
  
  if (!response.ok) {
    throw new Error(data.error || "Update failed");
  }
  
  // Handle missing keys redirect
  if (data.redirectUrl) {
    router.push(data.redirectUrl);
    return;
  }
  
  // Success - agent updated
  toast.success("Agent updated successfully!");
  return data.agent;
}

// Usage
await updateAgent("agent_abc123", {
  name: "New Name",
  temperature: 0.5
});

Update Languages

const response = await fetch(`/api/agents/${agentId}`, {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${sessionToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    languages: ["english", "urdu", "sindhi"]
  })
});

Change to Commercial Mode

// Only works for Owners/Admins
const response = await fetch(`/api/agents/${agentId}`, {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${sessionToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    mode: "commercial"
  })
});

if (response.status === 403) {
  console.error("Only owners/admins can create commercial agents");
}

Use Cases

// Only send fields you want to change
await updateAgent(agentId, {
  temperature: 0.5  // Only change temperature
});

Full Configuration Update

await updateAgent(agentId, {
  name: "New Name",
  description: "New description",
  sysMsg: "New system prompt...",
  languages: ["english"],
  model: "gpt_4o_mini",
  stt": "deepgram",
  voiceId: "cartesia-voice-123",
  greetingType: "agentFirst",
  greetingMessage: "Hello!",
  temperature: 0.7,
  inactivityTimeout: 30,
  mode: "public"
});

Architecture-Specific Update

// Pipeline agent update
await updateAgent(agentId, {
  agentArchitecture: "pipeline",
  voiceId: "cartesia-voice-456",
  model: "gpt_4o_mini",
  stt: "deepgram"
});

// Realtime agent update
await updateAgent(agentId, {
  agentArchitecture: "realtime",
  realtimeProvider: "gemini",
  voiceId: "gemini-leda-en"
});

// Text agent update
await updateAgent(agentId, {
  agentArchitecture: "text",
  model: "gpt_4o_mini"
});

Authorizations

x-api-key
string
header
required

Your TalkifAI API key. Generate from Studio → Settings → API Keys. Format: tk_live_...

Path Parameters

agentId
string
required

Body

application/json
name
string
description
string
sysMsg
string
model
string
stt
string
voiceId
string
realtimeProvider
enum<string>
Available options:
openai,
gemini
greetingType
enum<string>
Available options:
agentFirst,
userFirst
greetingMessage
string
lastMessage
string
temperature
number
inactivityTimeout
integer
Required range: 10 <= x <= 60
mode
enum<string>
Available options:
public,
private,
commercial
languages
string[]
functionCallingEnabled
boolean
enabledFunctions
string[]
enabledCustomFunctions
string[]

Response

Agent updated

success
boolean
data
object