# Update a prompt template div strong 🔨 In Development — This section is still being developed and may change. Updates an existing prompt template with new content, variables, or metadata. Creates a new version of the template while preserving the original for rollback if needed. Use this endpoint to modify prompt templates after creation. Updates create a new version of the template, maintaining a complete version history for auditing and rollback. #### Path Parameters **`prompt_id`** string *required* The unique identifier of the prompt template to update. #### Query Parameters **`organizationId`** string *required* The unique identifier of the organization that owns the prompt template. #### Request Body **`name`** string *optional* Update the human-readable name of the prompt template. **`description`** string *optional* Update the detailed description of the template's purpose and usage. **`content`** string *optional* Update the prompt template content. Changes to the content will be reflected in all future uses of this template. **`variables`** object *optional* Update the variable definitions for the template. Adding new variables, modifying types/descriptions, or changing required status. **`tags`** array *optional* Update the tags assigned to the template. Tags are used for categorization and filtering. **`isPublic`** boolean *optional* Update the public status of the template. Changing from private to public makes it discoverable in the template gallery. **`metadata`** object *optional* Update or add custom metadata to the template. **`versionNotes`** string *optional* A brief description of the changes made in this version. Used for version history tracking. #### Response Returns the updated prompt template object with the new version information: **`id`** string The unique identifier of the prompt template (unchanged). **`object`** string Always set to `"prompt"`. **`name`** string The updated name (or unchanged if not modified). **`description`** string The updated description (or unchanged if not modified). **`content`** string The updated prompt content (or unchanged if not modified). **`variables`** object The updated variable definitions (or unchanged if not modified). **`tags`** array The updated tags (or unchanged if not modified). **`isPublic`** boolean The updated public status (or unchanged if not modified). **`metadata`** object The updated metadata (or unchanged if not modified). **`createdAt`** integer Original creation timestamp (unchanged). **`updatedAt`** integer New timestamp reflecting the update time. **`version`** string New version identifier (auto-generated, typically increments from previous version). **`previousVersion`** string The version identifier of the previous version (for rollback reference). **`versionNotes`** string The notes provided for this version update. **`usage`** object *optional* Current usage statistics reflecting all versions of the template. ## Returns A [PromptResponse](#promptresponse) object containing the API response data. Update content ```bash curl -X PATCH "https://api.freddy.aitronos.com/v1/prompts/prompt_abc123?organizationId=org_abc123" \ -H "Authorization: Bearer $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content": "You are an expert code reviewer with a focus on {{focus_areas}}. Analyze this {{language}} code:\n\n{{code}}\n\nProvide feedback structured as:\n1. Strengths\n2. Areas for improvement\n3. Security considerations", "versionNotes": "Enhanced feedback structure and added security review" }' ``` ```python import requests import os response = requests.patch( f"https://api.freddy.aitronos.com/v1/prompts/prompt_abc123", headers={ "Authorization": f"Bearer {os.environ['FREDDY_API_KEY']}", "Content-Type": "application/json" }, params={ "organizationId": "org_abc123" }, json={ "content": "You are an expert code reviewer with a focus on {{focus_areas}}. Analyze this {{language}} code:\n\n{{code}}\n\nProvide feedback structured as:\n1. Strengths\n2. Areas for improvement\n3. Security considerations", "versionNotes": "Enhanced feedback structure and added security review" } ) updated_prompt = response.json() print(f"New version: {updated_prompt['version']}") print(f"Updated content preview: {updated_prompt['content'][:100]}...") ``` ```javascript const promptId = 'prompt_abc123'; const response = await fetch(`https://api.freddy.aitronos.com/v1/prompts/${promptId}?organizationId=org_abc123`, { method: 'PATCH', headers: { 'Authorization': `Bearer ${process.env.FREDDY_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ content: 'You are an expert code reviewer with a focus on {{focus_areas}}. Analyze this {{language}} code:\n\n{{code}}\n\nProvide feedback structured as:\n1. Strengths\n2. Areas for improvement\n3. Security considerations', versionNotes: 'Enhanced feedback structure and added security review' }) }); const updatedPrompt = await response.json(); console.log(`New version: ${updatedPrompt.version}`); console.log(`Updated content preview: ${updatedPrompt.content.substring(0, 100)}...`); ``` Update variables ```bash curl -X PATCH "https://api.freddy.aitronos.com/v1/prompts/prompt_abc123?organizationId=org_abc123" \ -H "Authorization: Bearer $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "variables": { "focus_areas": { "type": "string", "description": "Specific areas for code review (security, performance, etc.)", "required": true, "enum": ["security", "performance", "readability", "best-practices", "all"] }, "code": { "type": "string", "description": "The code snippet to review", "required": true }, "language": { "type": "string", "description": "Programming language", "required": true, "enum": ["javascript", "python", "java", "go", "rust", "typescript", "cpp", "c-sharp"] }, "project_context": { "type": "string", "description": "Additional project context or requirements", "required": false, "default": "Standard web application" } }, "versionNotes": "Updated variables: made focus_areas required with enum, added project_context" }' ``` ```python response = requests.patch( f"https://api.freddy.aitronos.com/v1/prompts/prompt_abc123", headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}, params={"organizationId": "org_abc123"}, json={ "variables": { "focus_areas": { "type": "string", "description": "Specific areas for code review (security, performance, etc.)", "required": True, "enum": ["security", "performance", "readability", "best-practices", "all"] }, "code": { "type": "string", "description": "The code snippet to review", "required": True }, "language": { "type": "string", "description": "Programming language", "required": True, "enum": ["javascript", "python", "java", "go", "rust", "typescript", "cpp", "c-sharp"] }, "project_context": { "type": "string", "description": "Additional project context or requirements", "required": False, "default": "Standard web application" } }, "versionNotes": "Updated variables: made focus_areas required with enum, added project_context" } ) ``` ```javascript const response = await fetch(`https://api.freddy.aitronos.com/v1/prompts/prompt_abc123?organizationId=org_abc123`, { method: 'PATCH', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ variables: { focus_areas: { type: 'string', description: 'Specific areas for code review (security, performance, etc.)', required: true, enum: ['security', 'performance', 'readability', 'best-practices', 'all'] }, code: { type: 'string', description: 'The code snippet to review', required: true }, language: { type: 'string', description: 'Programming language', required: true, enum: ['javascript', 'python', 'java', 'go', 'rust', 'typescript', 'cpp', 'c-sharp'] }, project_context: { type: 'string', description: 'Additional project context or requirements', required: false, default: 'Standard web application' } }, versionNotes: 'Updated variables: made focus_areas required with enum, added project_context' }) }); ``` Change public status ```bash curl -X PATCH "https://api.freddy.aitronos.com/v1/prompts/prompt_abc123?organizationId=org_abc123" \ -H "Authorization: Bearer $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "isPublic": true, "versionNotes": "Made template publicly available for organization-wide use" }' ``` ```python response = requests.patch( f"https://api.freddy.aitronos.com/v1/prompts/prompt_abc123", headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}, params={"organizationId": "org_abc123"}, json={ "isPublic": True, "versionNotes": "Made template publicly available for organization-wide use" } ) updated = response.json() print(f"Template is now public: {updated['isPublic']}") ``` ```javascript const response = await fetch(`https://api.freddy.aitronos.com/v1/prompts/prompt_abc123?organizationId=org_abc123`, { method: 'PATCH', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ isPublic: true, versionNotes: 'Made template publicly available for organization-wide use' }) }); const updated = await response.json(); console.log(`Template is now public: ${updated.isPublic}`); ``` Update metadata only ```bash curl -X PATCH "https://api.freddy.aitronos.com/v1/prompts/prompt_abc123?organizationId=org_abc123" \ -H "Authorization: Bearer $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "metadata": { "team": "engineering", "category": "code-quality", "last_reviewed": "2025-03-15", "approved_by": "cto" }, "versionNotes": "Updated metadata with team ownership and approval information" }' ``` ```python response = requests.patch( f"https://api.freddy.aitronos.com/v1/prompts/prompt_abc123", headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}, params={"organizationId": "org_abc123"}, json={ "metadata": { "team": "engineering", "category": "code-quality", "last_reviewed": "2025-03-15", "approved_by": "cto" }, "versionNotes": "Updated metadata with team ownership and approval information" } ) ``` ```javascript const response = await fetch(`https://api.freddy.aitronos.com/v1/prompts/prompt_abc123?organizationId=org_abc123`, { method: 'PATCH', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ metadata: { team: 'engineering', category: 'code-quality', last_reviewed: '2025-03-15', approved_by: 'cto' }, versionNotes: 'Updated metadata with team ownership and approval information' }) }); ``` #### Example Response ```json { "id": "prompt_abc123", "object": "prompt", "name": "Code Review Assistant", "description": "Reviews code pull requests and provides improvement suggestions", "content": "You are an expert code reviewer with a focus on {{focus_areas}}. Analyze this {{language}} code:\n\n{{code}}\n\nProvide feedback structured as:\n1. Strengths\n2. Areas for improvement\n3. Security considerations", "variables": { "focus_areas": { "type": "string", "description": "Areas to focus the review on (e.g., security, performance, readability)", "required": false, "default": "best practices" }, "code": { "type": "string", "description": "The code to review", "required": true }, "language": { "type": "string", "description": "Programming language of the code", "required": true, "enum": ["javascript", "python", "java", "go", "rust", "typescript"] } }, "tags": ["code-review", "development", "quality"], "isPublic": false, "metadata": { "team": "engineering", "category": "code-quality" }, "createdAt": 1735689600, "updatedAt": 1736208000, "version": "1.1.0", "previousVersion": "1.0.0", "versionNotes": "Enhanced feedback structure and added security review", "usage": { "totalCalls": 45, "lastUsedAt": 1736208000, "averageResponseTime": 2.3 } } ``` #### Error Responses **`404 Not Found`** ```json { "error": { "message": "Prompt template not found", "type": "not_found_error", "code": "prompt_not_found", "param": "prompt_id" } } ``` **`403 Forbidden`** ```json { "error": { "message": "Insufficient permissions to update this prompt template", "type": "permission_error", "code": "insufficient_permissions", "param": "prompt_id" } } ``` **`422 Validation Error`** ```json { "error": { "message": "Invalid variable type specified", "type": "invalid_request_error", "code": "invalid_variable_type", "param": "variables.code.type", "details": "Type must be one of: string, number, boolean, array, object, image, file" } } ``` ## Related Resources - [Create Prompt](/docs/api-reference/prompts/create) - [List Prompts](/docs/api-reference/prompts/list) - [Retrieve Prompt](/docs/api-reference/prompts/retrieve) - [Delete Prompt](/docs/api-reference/prompts/delete) - [Version History](#) (planned) - [Using Prompt Templates](/docs/api-reference/responses/create#prompt) **Note:** Updating a prompt template creates a new version but does not affect ongoing conversations or cached prompt results. All existing references to the template ID will use the latest version unless a specific version is requested.