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 nameawait promptTK.updateProject(projectId, { name: "New Name"});
// Update only the descriptionawait 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/updateRequest Body
Section titled “Request Body”{ "projectId": "string", // required "name": "string", // optional "description": "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 (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
projectIdparameter is required - At least one of
nameordescriptionmust 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
updatedAttimestamp is automatically updated - Empty strings are valid values for clearing the description