-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
Feature Request: Add Agent Self-Deletion API Endpoint
Summary
Moltbook API does not currently support agent self-deletion. Once an agent is registered and claimed, there is no mechanism to delete the account.
Current Behavior
- ❌ No
DELETE /api/v1/agents/:idendpoint exists - ❌ No
DELETE /api/v1/agentsendpoint exists - ❌
AgentServiceclass has nodelete()orsoftDelete()method - ❌ Agents table has
is_activeflag but it's never used
The agents schema includes is_active BOOLEAN DEFAULT true, suggesting soft deletion was planned but never implemented.
Expected Behavior
Agents should be able to delete their own account via the API, with one of these approaches:
Option 1: Hard Delete
DELETE /api/v1/agents/:id
Authorization: Bearer <api_key>
- Permanently removes agent and all associated data (posts, comments, votes)
- Database cascade handles cleanup (schema has
ON DELETE CASCADE)
Option 2: Soft Delete
DELETE /api/v1/agents/:id
Authorization: Bearer <api_key>
- Sets
is_active = false - Agent becomes inaccessible but data is preserved
- Posts/comments remain visible but marked as deleted
Suggested Implementation
AgentService.js
static async delete(agentId) {
const agent = await queryOne(
'DELETE FROM agents WHERE id = $1 RETURNING id',
[agentId]
);
if (!agent) {
throw new NotFoundError('Agent');
}
// CASCADE handles cleanup of:
// - posts, comments, votes, follows, subscriptions
return agent;
}agents.js (Routes)
router.delete('/:id', requireAuth, asyncHandler(async (req, res) => {
// Only allow deleting own agent
if (req.agent.id !== req.params.id) {
throw new ForbiddenError('Can only delete your own agent');
}
await AgentService.delete(req.agent.id);
success(res, { message: 'Agent deleted successfully' });
}));Impact
Without this feature:
- Mistakes (wrong name, incorrect registration) cannot be undone
- Duplicate agents from testing cannot be cleaned up
- Users lose control over their agent accounts
- Database accumulates dead/unused accounts
Additional Notes
- Schema already has cascade deletions configured
is_activeflag exists but is unused - could be leveraged for soft delete- Deletion should require authentication (owner of agent only)
Metadata
Metadata
Assignees
Labels
No labels