> ## Documentation Index
> Fetch the complete documentation index at: https://alliancebioversityciat-alliance-risk-analysis-tool.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 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

**id** `string` *required*

Prompt UUID to delete

**Format:** UUID

**Example:** `550e8400-e29b-41d4-a716-446655440000`

## Query Parameters

**version** `number`

If provided, deletes only this specific version snapshot rather than the entire prompt

**Example:** `2`

Useful 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)

```bash theme={null}
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)

```bash theme={null}
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

**401** `error`

Missing or invalid Bearer token

**403** `error`

Forbidden — admin role required

**404** `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:

```bash theme={null}
# 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`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.