Update Prompt
The updatePrompt endpoint allows you to update the output text of an existing prompt. This is useful when you want to manually edit or refine the generated prompt text without regenerating it entirely.
import { PromptTK } from "@devvle/ptk-api-sdk";
const promptTK = new PromptTK({ userId: "your-user-id", apiKey: "your-api-key",});
async function updatePrompt() { const promptId = "your-prompt-id"; const newPromptText = "This is the updated prompt text.";
try { const response = await promptTK.updatePrompt(promptId, newPromptText); console.log("Prompt updated:", response); } catch (error) { console.error("Error updating prompt:", error); }}
updatePrompt();Expected Output:
{ success: true, message: 'Prompt updated successfully', data: { recordId: 'your-prompt-id', promptName: 'Your Prompt Name', projectId: 'your-project-id', ownerId: 'your-user-id', createdAt: 1234567890, updatedAt: 1234567899, activeVersionId: 'version-id', latestVersionNumber: 1 }}The updatePrompt function makes a request to the following endpoint:
PUT /v1/prompts/update/:promptIdRequest Parameters
Section titled “Request Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
promptId | string | Yes | The ID of the prompt to update |
promptText | string | Yes | The new text to replace the prompt output |
Request Body
Section titled “Request Body”{ "promptText": "string" // required}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": "Prompt updated successfully", "data": { "recordId": "prompt-id", "promptName": "Prompt Name", "projectId": "project-id", "ownerId": "user-id", "createdAt": 1234567890, "updatedAt": 1234567899, "activeVersionId": "version-id", "latestVersionNumber": 1 }}On error, you may receive:
{ "success": false, "message": "User ID is required"}or
{ "success": false, "message": "promptId and promptText data are required"}or
{ "success": false, "message": "Updated Prompt not found"}or
{ "success": false, "message": "Failed to update prompt", "error": "...error message..."}- This endpoint updates the output field of the active version of the prompt, not the input template.
- The update only modifies the prompt text; it does not regenerate the prompt using AI.
- If you need to create a new version with different inputs or regenerate the prompt, use the Create Prompt Version endpoint instead.
- The
updatedAttimestamp will be automatically updated to reflect when the change was made. - This endpoint is intended for manual edits and refinements to existing prompt outputs.