Skip to main content
DELETE
Delete Prompt
Deletes a prompt and all its version history. If a specific version number is provided, only that version snapshot is deleted.

Authentication

Requires JWT Bearer token (Cognito) with admin role.

Path Parameters

string
required
Prompt UUID to deleteFormat: UUIDExample: 550e8400-e29b-41d4-a716-446655440000

Query Parameters

number
If provided, deletes only this specific version snapshot rather than the entire promptExample: 2Useful for cleaning up old version history without removing the prompt itself.

Response

Status: 204 No Content No response body is returned on successful deletion.

Example Request (Delete Entire Prompt)

Example Request (Delete Specific Version)

Error Responses

error
Missing or invalid Bearer token
error
Forbidden — admin role required
error
Prompt or version not found

Cascade Behavior

When deleting an entire prompt (no version parameter):
  • The prompt record is deleted from the prompts table
  • All version snapshots in prompt_versions are deleted (CASCADE)
  • All comments in prompt_comments are deleted (CASCADE)
  • All change records in prompt_changes are deleted (CASCADE)
When deleting a specific version (with version parameter):
  • Only the specified version snapshot is removed from prompt_versions
  • The prompt itself and other versions remain intact
  • A change record is created with type DELETE

Deletion Tracking

When a prompt is deleted:
  1. A final change record is created in prompt_changes with:
    • changeType: DELETE
    • authorId: User who deleted the prompt
    • createdAt: Deletion timestamp
  2. The change record persists even after the prompt is deleted (foreign key allows NULL)
This provides an audit trail of deleted prompts.

Soft Delete Alternative

Consider using the isActive flag as a soft delete:
Benefits:
  • Preserves full history and comments
  • Can be reactivated later
  • Allows filtering out inactive prompts in the UI

Source Code

Implementation: packages/api/src/prompts/prompts.controller.ts:179