Skip to content

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

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();
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/delete
{
"projectId": "string", // required
"transferToProjectId": "string" // optional
}
HeaderValue
Content-Typeapplication/json
AuthorizationBearer your-api-key
x-user-idyour-user-id

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 projectId parameter is required
  • The transferToProjectId parameter is optional
  • If transferToProjectId is provided, all prompts from the deleted project will be transferred to the target project
  • If transferToProjectId is 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
  • 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