Update Agent
Update an existing agent's configuration
Updates an existing agent's configuration. Only specified fields are updated; omitted fields remain unchanged.
Endpoint
PUT https://api.ayra.ai/v1/agents/{agent_id}Authentication
Requires API key with agents:write permission.
Path Parameters
agent_idrequiredThe unique identifier of the agent to update
Request Parameters
All parameters are optional. Only include fields you want to update.
• name - Agent name. Maximum 100 characters.
• voice_id - Voice to use from the platform's voice library.
• language - Primary language. ISO 639-1 code.
• system_prompt - Agent behavior and personality instructions. Maximum 10,000 characters.
• welcome_message - Initial greeting. Maximum 500 characters.
• transfer_number - Escalation phone number. E.164 format.
• business_hours - Operating hours configuration.
• recording_enabled - Whether to record calls.
• transcription_enabled - Whether to transcribe calls.
• status - Agent status. Valid values: active, paused, archived
• metadata - Custom key-value data.
Request Examples
cURL Example:
curl -X PUT https://api.ayra.ai/v1/agents/agent_abc123xyz789 \
-H "Authorization: Bearer sk_live_abc123xyz789" \
-H "Content-Type: application/json" \
-d '{
"system_prompt": "You are a helpful and friendly customer support agent for Acme Corporation. You help customers with order inquiries, shipping questions, product information, and returns. Always be professional, empathetic, and solution-oriented. If you cannot help with something, offer to transfer to a human agent.",
"welcome_message": "Thank you for calling Acme Corporation. This is your AI assistant. How may I help you today?",
"metadata": {
"version": "2.0",
"last_updated_by": "john@company.com"
}
}'JavaScript Example:
async function updateAgent(agentId, updates) {
try {
const response = await axios.put(
`https://api.ayra.ai/v1/agents/${agentId}`,
updates,
{
headers: {
'Authorization': 'Bearer sk_live_abc123xyz789',
'Content-Type': 'application/json'
}
}
);
console.log('Agent updated:', response.data);
return response.data;
} catch (error) {
console.error('Error updating agent:', error.response.data);
throw error;
}
}
// Example: Update system prompt
updateAgent('agent_abc123xyz789', {
system_prompt: 'You are a helpful customer support agent...',
metadata: {
version: '2.0',
last_updated_by: 'john@company.com'
}
});Python Example:
def update_agent(agent_id, updates):
url = f'https://api.ayra.ai/v1/agents/{agent_id}'
headers = {
'Authorization': 'Bearer sk_live_abc123xyz789',
'Content-Type': 'application/json'
}
response = requests.put(url, json=updates, headers=headers)
if response.status_code == 200:
print('Agent updated:', response.json())
return response.json()
else:
print('Error:', response.json())
raise Exception(f'Failed to update agent: {response.status_code}')
# Example: Update agent voice
update_agent('agent_abc123xyz789', {
'voice_id': 'voice_professional_male_1',
'metadata': {
'version': '2.0'
}
})Response
Success Response (200 OK):
{
"data": {
"id": "agent_abc123xyz789",
"name": "Customer Support Agent",
"phone_number": "+15551234567",
"voice_platform": "vapi",
"voice_id": "voice_professional_female_1",
"language": "en",
"system_prompt": "You are a helpful and friendly customer support agent for Acme Corporation...",
"welcome_message": "Thank you for calling Acme Corporation. This is your AI assistant. How may I help you today?",
"transfer_number": "+15559876543",
"business_hours": {
"timezone": "America/New_York",
"schedule": [...]
},
"recording_enabled": true,
"transcription_enabled": true,
"status": "active",
"metadata": {
"client_id": "client_789",
"department": "support",
"version": "2.0",
"last_updated_by": "john@company.com"
},
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T14:22:00Z"
},
"meta": {
"request_id": "req_update_xyz456",
"timestamp": "2025-01-15T14:22:00Z"
}
}Error Responses
404 Not Found:
{
"error": {
"type": "not_found",
"message": "Agent not found",
"code": "agent_not_found",
"agent_id": "agent_invalid123"
}
}400 Bad Request - Invalid Parameter:
{
"error": {
"type": "invalid_request",
"message": "Invalid language code",
"code": "invalid_parameter",
"field": "language"
}
}Notes
- • Updates take effect immediately for future calls
- • Active calls when update occurs continue with previous configuration
- • Changing voice platforms is not supported via update - create a new agent instead
- • Phone numbers cannot be changed via update - contact support for number changes
- • The
updated_attimestamp reflects when the agent was last modified
Ready to transform your agency?
Start building with Ayra today. No credit card required.