Delete Project
The deleteProject endpoint allows you to delete a project. You can optionally transfer all prompts from the deleted project to another project, or delete the project while keeping the prompts orphaned (they remain in the system but are not associated with any project).
Delete with Prompt Transfer
Section titled “Delete with Prompt Transfer”import { PromptTK } from "@devvle/ptk-api-sdk";
const promptTK = new PromptTK({ userId: "your-user-id", apiKey: "your-api-key",});
async function deleteProjectWithTransfer() { const projectToDelete = "abc123xyz789"; const targetProject = "def456uvw012"; // Transfer prompts to this project
try { const response = await promptTK.deleteProject( projectToDelete, targetProject ); console.log("Project deleted and prompts transferred:", response); } catch (error) { console.error("Error deleting project:", error); }}
deleteProjectWithTransfer();Delete without Transfer
Section titled “Delete without Transfer”async function deleteProjectOnly() { const projectToDelete = "abc123xyz789";
try { const response = await promptTK.deleteProject(projectToDelete); console.log("Project deleted:", response); } catch (error) { console.error("Error deleting project:", error); }}
deleteProjectOnly();Expected Output (with transfer):
{ success: true, message: 'Project deleted successfully and prompts transferred', data: { deletedProjectId: 'abc123xyz789', transferredTo: 'def456uvw012', promptsTransferred: 15 }}Expected Output (without transfer):
{ success: true, message: 'Project deleted successfully', data: { deletedProjectId: 'abc123xyz789' }}The deleteProject function makes a request to the following endpoint:
DELETE /v1/projects/deleteRequest Body
Section titled “Request Body”{ "projectId": "string", // required "transferToProjectId": "string" // optional}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 with transfer (200 OK):
{ "success": true, "message": "Project deleted successfully and prompts transferred", "data": { "deletedProjectId": "string", "transferredTo": "string", "promptsTransferred": "number" }}On success without transfer (200 OK):
{ "success": true, "message": "Project deleted successfully", "data": { "deletedProjectId": "string" }}On error:
{ "success": false, "message": "Project ID is required"}or
{ "success": false, "message": "Project not found"}or
{ "success": false, "message": "Unauthorized access to project"}or
{ "success": false, "message": "Transfer target project not found"}- The
projectIdparameter is required - The
transferToProjectIdparameter is optional - If
transferToProjectIdis provided, all prompts from the deleted project will be transferred to the target project - If
transferToProjectIdis not provided, prompts remain in the system but become orphaned - The endpoint verifies that both projects belong to the authenticated user
- You cannot transfer prompts to the same project being deleted
- The target project must exist and belong to the user
- Deletion is permanent and cannot be undone
Best Practices
Section titled “Best Practices”- Always transfer prompts when possible to avoid orphaned data
- Verify the target project exists before attempting to delete
- Get user confirmation before deleting a project, especially if it contains many prompts
- Create a backup project if you need to consolidate multiple projects into one