Skip to main content

Endpoint

Authentication

Requires JWT authentication via Authorization: Bearer <token> header.

Description

Permanently deletes an agent, including all its versions, configuration, and associated triggers. This action is irreversible. What Gets Deleted:
  • Agent record
  • All versions (v1, v2, v3, etc.)
  • Version configurations (system prompts, tools, MCPs)
  • Agent triggers (if any)
  • Agent cache entries
What Is NOT Deleted:
  • Agent runs (preserved for history)
  • Threads created by this agent
  • Messages generated by this agent

Path Parameters

string
required
The unique identifier (UUID) of the agent to delete.

Restrictions

The following agents cannot be deleted:
  1. Default Agent: Agents with is_default: true must first be unset as default
  2. Suna System Agent: Agents with metadata.is_suna_default: true are protected
Attempting to delete protected agents returns 400 Bad Request.

Response

string
Success confirmation message

Success Response

Examples

Error Responses

error
Agent does not exist or user does not have access
error
User does not own this agent or lacks permission to delete
error
Attempting to delete a protected agent
Or:
error
Missing or invalid authentication token
error
Server error during deletion

Safe Deletion Pattern

Before deleting an agent, ensure it’s not the default:

Cleanup Actions

When an agent is deleted, the following cleanup occurs automatically:
  1. Agent Record: Removed from agents table
  2. Versions: All version records deleted from agent_versions table
  3. Triggers: Associated triggers deleted via trigger service
  4. Cache: Agent configuration cache invalidated
  5. User Limits Cache: Agent count cache invalidated to reflect new limit

Trigger Cleanup

If the agent has configured triggers (e.g., scheduled runs, webhooks), they are automatically deleted:

Recovering from Accidental Deletion

Agent deletion is permanent and cannot be undone. To minimize risk:
  1. Export Before Deleting: Use the export endpoint to save configuration
  2. Verify Agent ID: Double-check the agent ID before deletion
  3. Check Dependencies: Ensure no active runs are using this agent

Export Before Delete

Notes

  • Irreversible: Deletion is permanent; consider exporting first
  • Default Protection: Cannot delete default agent; unset default first
  • System Protection: Suna and other system agents cannot be deleted
  • History Preserved: Agent runs and messages remain in the database for audit purposes
  • Cache Invalidation: Triggers automatic cache cleanup
  • Trigger Cleanup: All associated triggers are deleted