Delete Prompt
The deletePrompt endpoint allows you to permanently delete a prompt and all its associated versions. This action cannot be undone, so use with caution.
import { PromptTK } from "@devvle/ptk-api-sdk";
const promptTK = new PromptTK({ userId: "your-user-id", apiKey: "your-api-key",});
async function deletePrompt() { const promptId = "your-prompt-id";
try { const response = await promptTK.deletePrompt(promptId); console.log("Prompt deleted:", response); } catch (error) { console.error("Error deleting prompt:", error); }}
deletePrompt();Expected Output:
{ success: true, message: 'Prompt deleted successfully'}The deletePrompt function makes a request to the following endpoint:
DELETE /v1/prompts/delete/:promptIdRequest Parameters
Section titled “Request Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
promptId | string | Yes | The ID of the prompt to delete |
Request Body
Section titled “Request Body”{ "promptId": "string" // required}Headers
Section titled “Headers”| Header | Value |
|---|---|
Content-Type | application/json |
Authorization | Bearer your-api-key |
x-user-id | your-user-id |
Response
Section titled “Response”On success (200 OK):
{ "success": true, "message": "Prompt deleted successfully"}On error, you may receive:
{ "success": false, "message": "User ID is required"}or
{ "success": false, "message": "Prompt ID is required"}or
{ "success": false, "message": "Prompt not deleted"}or
{ "success": false, "message": "Failed to delete prompt", "error": "...error message..."}Important Notes
Section titled “Important Notes”⚠️ WARNING: This action is permanent and cannot be undone!
-
Deleting a prompt will permanently remove:
- The prompt record
- All versions of the prompt
- All associated metadata
-
The deletion is performed as a batch operation to ensure data consistency
-
Only the owner of the prompt (matching the
userId) can delete it -
If the prompt is not found or doesn’t belong to the user, a 404 error is returned
-
This operation does not affect the project that contains the prompt
Use Cases
Section titled “Use Cases”- Cleaning up test prompts
- Removing outdated or unused prompts
- Managing storage and organization
- Compliance with data retention policies
Best Practices
Section titled “Best Practices”- Always confirm before deletion - Implement a confirmation dialog in your UI
- Consider archiving instead - If you might need the data later, consider an archive feature
- Backup important prompts - Export or backup prompts before deletion if needed
- Use with caution in production - Ensure proper authorization checks in your application
Related Endpoints
Section titled “Related Endpoints”- Get Prompt by ID - Retrieve prompt details before deletion
- Update Prompt - Update prompt instead of deleting
- Get All Prompts - List all prompts to find the one to delete
Example with Confirmation
Section titled “Example with Confirmation”import { PromptTK } from "@devvle/ptk-api-sdk";
const promptTK = new PromptTK({ userId: "your-user-id", apiKey: "your-api-key",});
async function deletePromptWithConfirmation(promptId) { // Get prompt details first const prompt = await promptTK.fetchPromptById(promptId);
// Show confirmation (in a real app, this would be a UI dialog) console.log(`Are you sure you want to delete "${prompt.data.promptName}"?`); console.log("This action cannot be undone!");
// In a real application, wait for user confirmation here const confirmed = true; // Replace with actual confirmation logic
if (confirmed) { try { const response = await promptTK.deletePrompt(promptId); if (response.success) { console.log("✅ Prompt deleted successfully"); } } catch (error) { console.error("❌ Failed to delete prompt:", error); } } else { console.log("Deletion cancelled"); }}