Skip to content

Update Project

The updateProject endpoint allows you to modify a project’s name and/or description. This is useful when you need to rename a project or update its description as your project evolves.

import { PromptTK } from "@devvle/ptk-api-sdk";
const promptTK = new PromptTK({
userId: "your-user-id",
apiKey: "your-api-key",
});
async function updateProject() {
const projectId = "abc123xyz789";
const updates = {
name: "Updated Project Name",
description: "Updated project description"
};
try {
const response = await promptTK.updateProject(projectId, updates);
console.log("Project updated:", response);
} catch (error) {
console.error("Error updating project:", error);
}
}
updateProject();

You can also update just the name or just the description:

// Update only the name
await promptTK.updateProject(projectId, {
name: "New Name"
});
// Update only the description
await promptTK.updateProject(projectId, {
description: "New description"
});

Expected Output:

{
success: true,
message: 'Project updated successfully',
data: {
id: 'abc123xyz789',
name: 'Updated Project Name',
description: 'Updated project description',
updatedAt: '2024-01-15T12:00:00.000Z'
}
}

The updateProject function makes a request to the following endpoint:

PUT /v1/projects/update
{
"projectId": "string", // required
"name": "string", // optional
"description": "string" // optional
}
HeaderValue
Content-Typeapplication/json
AuthorizationBearer your-api-key
x-user-idyour-user-id

On success (200 OK):

{
"success": true,
"message": "Project updated successfully",
"data": {
"id": "string",
"name": "string",
"description": "string",
"updatedAt": "ISO 8601 timestamp"
}
}

On error:

{
"success": false,
"message": "Project ID is required"
}

or

{
"success": false,
"message": "At least one field (name or description) must be provided for update"
}

or

{
"success": false,
"message": "Project not found"
}

or

{
"success": false,
"message": "Unauthorized access to project"
}
  • The projectId parameter is required
  • At least one of name or description must be provided in the update object
  • You can update both fields or just one field
  • The endpoint verifies that the project belongs to the authenticated user
  • The updatedAt timestamp is automatically updated
  • Empty strings are valid values for clearing the description