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
Prompt UUID to deleteFormat: UUIDExample: 550e8400-e29b-41d4-a716-446655440000
Query Parameters
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)
curl -X DELETE https://api.example.com/api/admin/prompts/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Example Request (Delete Specific Version)
curl -X DELETE "https://api.example.com/api/admin/prompts/550e8400-e29b-41d4-a716-446655440000?version=2" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Error Responses
Missing or invalid Bearer token
Forbidden — admin role required
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:
- A final change record is created in
prompt_changes with:
changeType: DELETE
authorId: User who deleted the prompt
createdAt: Deletion timestamp
- 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:
# Instead of deleting, deactivate the prompt
curl -X PUT https://api.example.com/api/admin/prompts/550e8400-e29b-41d4-a716-446655440000/update \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "isActive": false }'
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