Ayra AI
|Docs

Delete Agent

Delete an agent permanently

Deletes an agent permanently. This action cannot be undone.

Endpoint

DELETE https://api.ayra.ai/v1/agents/{agent_id}

Authentication

Requires API key with agents:write permission.

Path Parameters

agent_idrequired

The unique identifier of the agent to delete

Request Examples

cURL Example:

curl -X DELETE https://api.ayra.ai/v1/agents/agent_abc123xyz789 \
  -H "Authorization: Bearer sk_live_abc123xyz789"

JavaScript Example:

async function deleteAgent(agentId) {
  try {
    const response = await axios.delete(
      `https://api.ayra.ai/v1/agents/${agentId}`,
      {
        headers: {
          'Authorization': 'Bearer sk_live_abc123xyz789'
        }
      }
    );
    
    console.log('Agent deleted successfully');
    return response.data;
  } catch (error) {
    console.error('Error deleting agent:', error.response.data);
    throw error;
  }
}

deleteAgent('agent_abc123xyz789');

Python Example:

def delete_agent(agent_id):
    url = f'https://api.ayra.ai/v1/agents/{agent_id}'
    headers = {
        'Authorization': 'Bearer sk_live_abc123xyz789'
    }
    
    response = requests.delete(url, headers=headers)
    
    if response.status_code == 204:
        print('Agent deleted successfully')
        return True
    else:
        print('Error:', response.json())
        raise Exception(f'Failed to delete agent: {response.status_code}')

delete_agent('agent_abc123xyz789')

Response

Success Response (204 No Content):

No response body. HTTP 204 status indicates successful deletion.

Error Responses

404 Not Found:

{
  "error": {
    "type": "not_found",
    "message": "Agent not found",
    "code": "agent_not_found",
    "agent_id": "agent_invalid123"
  }
}

409 Conflict - Active Calls:

{
  "error": {
    "type": "conflict",
    "message": "Cannot delete agent with active calls",
    "code": "agent_has_active_calls",
    "active_calls": 2
  }
}

Notes

  • • Deletion is permanent and cannot be undone
  • • Agents with active calls cannot be deleted. Wait for calls to end or force-terminate them first.
  • • Historical conversation data is retained even after agent deletion for compliance and analytics
  • • Phone numbers are released and may be reassigned after deletion
  • • Consider archiving agents instead of deleting if you might need to restore them

Alternative: Archive Agent

Instead of deleting, consider archiving to preserve data while stopping new calls:

// Archive instead of delete
await updateAgent(agentId, { status: 'archived' });

Archived agents:

  • • Stop accepting new calls
  • • Preserve all configuration and historical data
  • • Can be reactivated by changing status back to active
  • • Don't count against agent limits

Ready to transform your agency?

Start building with Ayra today. No credit card required.