Skip to content

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/:promptId
ParameterTypeRequiredDescription
promptIdstringYesThe ID of the prompt to delete
{
"promptId": "string" // required
}
HeaderValue
Content-Typeapplication/json
AuthorizationBearer your-api-key
x-user-idyour-user-id

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..."
}

⚠️ 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

  • Cleaning up test prompts
  • Removing outdated or unused prompts
  • Managing storage and organization
  • Compliance with data retention policies
  1. Always confirm before deletion - Implement a confirmation dialog in your UI
  2. Consider archiving instead - If you might need the data later, consider an archive feature
  3. Backup important prompts - Export or backup prompts before deletion if needed
  4. Use with caution in production - Ensure proper authorization checks in your application
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");
}
}