Skip to main content

Overview

The delete_agent function permanently deletes an AI agent from the system.

Function Signature

pub async fn delete_agent(agent_id: &str) -> Result<()>

Parameters

agent_id
&str
required
The unique identifier of the agent to delete

Return Value

Returns Result<()> indicating success or failure.

Basic Usage

use wacht::api::agents::*;

delete_agent("52057194421551105").await?;
println!("Agent deleted successfully");

Error Handling

match delete_agent("52057194421551105").await {
    Ok(()) => {
        println!("Agent deleted successfully");
    }
    Err(Error::Api { status, message, .. }) => {
        match status.as_u16() {
            404 => println!("Agent not found"),
            403 => println!("Access denied: {}", message),
            409 => println!("Cannot delete agent with active workflows: {}", message),
            _ => println!("API error {}: {}", status, message),
        }
    }
    Err(e) => println!("Request failed: {}", e),
}

Important Notes

  • This operation is irreversible
  • All agent data including conversation history will be deleted
  • Agents connected to active workflows cannot be deleted
  • You must have appropriate permissions to delete agents

Rate Limits

  • Delete operations: 20 requests per minute
  • Burst limit: 5 requests per second