# Delete a prompt template div strong 🔨 In Development — This section is still being developed and may change. Permanently deletes a prompt template and all its versions from the system. This action is irreversible and will remove the template from all references and usage history. Use this endpoint to remove prompt templates that are no longer needed. Deleted templates cannot be recovered, so ensure you have backups or alternative templates before deletion. #### Path Parameters **`prompt_id`** string *required* The unique identifier of the prompt template to delete. #### Query Parameters **`organizationId`** string *required* The unique identifier of the organization that owns the prompt template. **`confirmDeletion`** string *optional* Safety parameter requiring explicit confirmation. Must be set to `"confirmed"` to actually perform the deletion. Without this parameter, the request will return a 400 error. #### Response **`id`** string The identifier of the deleted prompt template (for confirmation). **`object`** string Always set to `"prompt"`. **`name`** string The name of the deleted prompt template (for confirmation). **`deleted`** boolean Always `true` when deletion is successful. **`message`** string Confirmation message: `"Prompt template permanently deleted"`. #### Important Notes - **Irreversible**: Once deleted, the prompt template and all its versions cannot be recovered. - **Usage Impact**: Any active conversations or cached results using this template will continue to work with the last known version, but new requests will fail with a 404 error. - **References**: Update any code or configurations that reference the deleted template ID. - **Permissions**: Only organization owners and template administrators can delete templates. - **Audit Trail**: Deletion events are logged in the organization's audit log for compliance and tracking. ## Returns A [DeletePromptResponse](#deletepromptresponse) object containing the API response data. Safe deletion with confirmation ```bash curl -X DELETE "https://api.freddy.aitronos.com/v1/prompts/prompt_abc123?organizationId=org_abc123&confirmDeletion=confirmed" \ -H "Authorization: Bearer $FREDDY_API_KEY" ``` ```python import requests import os prompt_id = "prompt_abc123" response = requests.delete( f"https://api.freddy.aitronos.com/v1/prompts/{prompt_id}", headers={ "Authorization": f"Bearer {os.environ['FREDDY_API_KEY']}" }, params={ "organizationId": "org_abc123", "confirmDeletion": "confirmed" } ) if response.status_code == 200: result = response.json() print(f"Deleted: {result['name']} ({result['id']})") else: print(f"Error: {response.status_code} - {response.text}") ``` ```javascript const promptId = 'prompt_abc123'; const response = await fetch(`https://api.freddy.aitronos.com/v1/prompts/${promptId}?organizationId=org_abc123&confirmDeletion=confirmed`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${process.env.FREDDY_API_KEY}` } }); if (response.ok) { const result = await response.json(); console.log(`Deleted: ${result.name} (${result.id})`); } else { console.error(`Error: ${response.status} - ${await response.text()}`); } ``` **Response:** ```json { "id": "prompt_abc123", "object": "prompt", "name": "Deprecated Code Review Template", "deleted": true, "message": "Prompt template permanently deleted" } ``` Attempt without confirmation (fails) ```bash curl -X DELETE "https://api.freddy.aitronos.com/v1/prompts/prompt_abc123?organizationId=org_abc123" \ -H "Authorization: Bearer $FREDDY_API_KEY" ``` ```json { "error": { "message": "Deletion confirmation required", "type": "invalid_request_error", "code": "confirmation_required", "param": "confirmDeletion", "details": "Set confirmDeletion=confirmed to proceed with deletion" } } ``` ```python response = requests.delete( f"https://api.freddy.aitronos.com/v1/prompts/{prompt_id}", headers={"Authorization": f"Bearer {api_key}"}, params={"organizationId": "org_abc123"} # Note: missing confirmDeletion parameter ) if response.status_code == 400: error = response.json() print(f"Error: {error['error']['message']}") print(f"To fix: Add confirmDeletion='confirmed' parameter") ``` ```javascript const response = await fetch(`https://api.freddy.aitronos.com/v1/prompts/${promptId}?organizationId=org_abc123`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${apiKey}` } // Note: missing confirmDeletion parameter }); if (response.status === 400) { const error = await response.json(); console.error(`Error: ${error.error.message}`); console.log('To fix: Add confirmDeletion=confirmed parameter'); } ``` Delete multiple templates ```python import requests def delete_prompt_batch(prompt_ids, organization_id): """Delete multiple prompt templates with confirmation""" deleted = [] errors = [] for prompt_id in prompt_ids: try: response = requests.delete( f"https://api.freddy.aitronos.com/v1/prompts/{prompt_id}", headers={"Authorization": f"Bearer {api_key}"}, params={ "organizationId": organization_id, "confirmDeletion": "confirmed" } ) if response.status_code == 200: result = response.json() deleted.append({ "id": result["id"], "name": result["name"], "message": result["message"] }) else: errors.append({ "id": prompt_id, "status": response.status_code, "error": response.json() }) except Exception as e: errors.append({ "id": prompt_id, "error": str(e) }) return {"deleted": deleted, "errors": errors} # Usage prompts_to_delete = ["prompt_abc123", "prompt_def456", "prompt_ghi789"] result = delete_prompt_batch(prompts_to_delete, "org_abc123") print(f"Successfully deleted: {len(result['deleted'])}") print(f"Errors: {len(result['errors'])}") for error in result['errors']: print(f"Failed to delete {error['id']}: {error.get('error', {}).get('message', 'Unknown error')}") ``` ```javascript async function deletePromptBatch(promptIds, organizationId) { const deleted = []; const errors = []; for (const promptId of promptIds) { try { const response = await fetch(`https://api.freddy.aitronos.com/v1/prompts/${promptId}?organizationId=${organizationId}&confirmDeletion=confirmed`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${apiKey}` } }); if (response.ok) { const result = await response.json(); deleted.push({ id: result.id, name: result.name, message: result.message }); } else { const error = await response.json(); errors.push({ id: promptId, status: response.status, error: error }); } } catch (e) { errors.push({ id: promptId, error: e.message }); } } return { deleted, errors }; } // Usage const promptsToDelete = ['prompt_abc123', 'prompt_def456', 'prompt_ghi789']; const result = await deletePromptBatch(promptsToDelete, 'org_abc123'); console.log(`Successfully deleted: ${result.deleted.length}`); console.log(`Errors: ${result.errors.length}`); result.errors.forEach(error => { console.log(`Failed to delete ${error.id}: ${error.error?.message || 'Unknown error'}`); }); ``` Error responses ```json { "error": { "message": "Prompt template not found", "type": "not_found_error", "code": "prompt_not_found", "param": "prompt_id" } } ``` ```json { "error": { "message": "Insufficient permissions to delete this prompt template", "type": "permission_error", "code": "insufficient_permissions", "param": "prompt_id", "details": "Only organization owners can delete public templates" } } ``` ```json { "error": { "message": "Cannot delete template currently in use", "type": "invalid_request_error", "code": "template_in_use", "param": "prompt_id", "details": "This template is referenced in 3 active assistant configurations. Remove references first." } } ``` ## Important Considerations ### Before Deletion 1. **Check Usage**: Review the template's usage statistics to understand its impact 2. **Update References**: Modify any assistants, workflows, or code that reference this template 3. **Backup Content**: Copy the template content and variables before permanent deletion 4. **Notify Team**: Inform team members if the template is shared or widely used 5. **Test Impact**: Verify that deleting the template doesn't break existing functionality ### After Deletion - **Monitor Logs**: Watch for 404 errors in application logs related to the deleted template - **Update Documentation**: Remove references from internal documentation and READMEs - **Clean Cache**: Clear any cached prompt results or compiled templates - **Audit Trail**: Review the audit log entry for the deletion event ### Alternatives to Deletion - **Deprecate**: Add a `deprecated: true` flag to the metadata and create a replacement - **Archive**: Set `isPublic: false` and add archival metadata instead of deleting - **Version Control**: Create a new version with empty content rather than deleting ## Related Resources - [Create Prompt](/docs/api-reference/prompts/create) - [List Prompts](/docs/api-reference/prompts/list) - [Retrieve Prompt](/docs/api-reference/prompts/retrieve) - [Update Prompt](/docs/api-reference/prompts/update) - [Audit Logs](/docs/api-reference/audit-logs/list) - [Using Prompt Templates](/docs/api-reference/responses/create#prompt) **Safety Note**: The `confirmDeletion` parameter prevents accidental deletions. Always include it in production code to avoid unintended data loss.