Update Prompt
curl --request PUT \
--url https://api.example.com/api/admin/prompts/:id/update \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"section": "<string>",
"subSection": "<string>",
"route": "<string>",
"categories": [
{}
],
"tags": [
{}
],
"systemPrompt": "<string>",
"userPromptTemplate": "<string>",
"tone": "<string>",
"outputFormat": "<string>",
"fewShot": [
{}
],
"context": {},
"isActive": true
}
'import requests
url = "https://api.example.com/api/admin/prompts/:id/update"
payload = {
"name": "<string>",
"section": "<string>",
"subSection": "<string>",
"route": "<string>",
"categories": [{}],
"tags": [{}],
"systemPrompt": "<string>",
"userPromptTemplate": "<string>",
"tone": "<string>",
"outputFormat": "<string>",
"fewShot": [{}],
"context": {},
"isActive": True
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
section: '<string>',
subSection: '<string>',
route: '<string>',
categories: [{}],
tags: [{}],
systemPrompt: '<string>',
userPromptTemplate: '<string>',
tone: '<string>',
outputFormat: '<string>',
fewShot: [{}],
context: {},
isActive: true
})
};
fetch('https://api.example.com/api/admin/prompts/:id/update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/admin/prompts/:id/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'section' => '<string>',
'subSection' => '<string>',
'route' => '<string>',
'categories' => [
[
]
],
'tags' => [
[
]
],
'systemPrompt' => '<string>',
'userPromptTemplate' => '<string>',
'tone' => '<string>',
'outputFormat' => '<string>',
'fewShot' => [
[
]
],
'context' => [
],
'isActive' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/admin/prompts/:id/update"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"section\": \"<string>\",\n \"subSection\": \"<string>\",\n \"route\": \"<string>\",\n \"categories\": [\n {}\n ],\n \"tags\": [\n {}\n ],\n \"systemPrompt\": \"<string>\",\n \"userPromptTemplate\": \"<string>\",\n \"tone\": \"<string>\",\n \"outputFormat\": \"<string>\",\n \"fewShot\": [\n {}\n ],\n \"context\": {},\n \"isActive\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.example.com/api/admin/prompts/:id/update")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"section\": \"<string>\",\n \"subSection\": \"<string>\",\n \"route\": \"<string>\",\n \"categories\": [\n {}\n ],\n \"tags\": [\n {}\n ],\n \"systemPrompt\": \"<string>\",\n \"userPromptTemplate\": \"<string>\",\n \"tone\": \"<string>\",\n \"outputFormat\": \"<string>\",\n \"fewShot\": [\n {}\n ],\n \"context\": {},\n \"isActive\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/admin/prompts/:id/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"section\": \"<string>\",\n \"subSection\": \"<string>\",\n \"route\": \"<string>\",\n \"categories\": [\n {}\n ],\n \"tags\": [\n {}\n ],\n \"systemPrompt\": \"<string>\",\n \"userPromptTemplate\": \"<string>\",\n \"tone\": \"<string>\",\n \"outputFormat\": \"<string>\",\n \"fewShot\": [\n {}\n ],\n \"context\": {},\n \"isActive\": true\n}"
response = http.request(request)
puts response.read_body{
"400": {},
"401": {},
"403": {},
"404": {},
"409": {},
"data": {}
}Prompts
Update Prompt
PUT
/
api
/
admin
/
prompts
/
:id
/
update
Update Prompt
curl --request PUT \
--url https://api.example.com/api/admin/prompts/:id/update \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"section": "<string>",
"subSection": "<string>",
"route": "<string>",
"categories": [
{}
],
"tags": [
{}
],
"systemPrompt": "<string>",
"userPromptTemplate": "<string>",
"tone": "<string>",
"outputFormat": "<string>",
"fewShot": [
{}
],
"context": {},
"isActive": true
}
'import requests
url = "https://api.example.com/api/admin/prompts/:id/update"
payload = {
"name": "<string>",
"section": "<string>",
"subSection": "<string>",
"route": "<string>",
"categories": [{}],
"tags": [{}],
"systemPrompt": "<string>",
"userPromptTemplate": "<string>",
"tone": "<string>",
"outputFormat": "<string>",
"fewShot": [{}],
"context": {},
"isActive": True
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
section: '<string>',
subSection: '<string>',
route: '<string>',
categories: [{}],
tags: [{}],
systemPrompt: '<string>',
userPromptTemplate: '<string>',
tone: '<string>',
outputFormat: '<string>',
fewShot: [{}],
context: {},
isActive: true
})
};
fetch('https://api.example.com/api/admin/prompts/:id/update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/admin/prompts/:id/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'section' => '<string>',
'subSection' => '<string>',
'route' => '<string>',
'categories' => [
[
]
],
'tags' => [
[
]
],
'systemPrompt' => '<string>',
'userPromptTemplate' => '<string>',
'tone' => '<string>',
'outputFormat' => '<string>',
'fewShot' => [
[
]
],
'context' => [
],
'isActive' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/admin/prompts/:id/update"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"section\": \"<string>\",\n \"subSection\": \"<string>\",\n \"route\": \"<string>\",\n \"categories\": [\n {}\n ],\n \"tags\": [\n {}\n ],\n \"systemPrompt\": \"<string>\",\n \"userPromptTemplate\": \"<string>\",\n \"tone\": \"<string>\",\n \"outputFormat\": \"<string>\",\n \"fewShot\": [\n {}\n ],\n \"context\": {},\n \"isActive\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.example.com/api/admin/prompts/:id/update")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"section\": \"<string>\",\n \"subSection\": \"<string>\",\n \"route\": \"<string>\",\n \"categories\": [\n {}\n ],\n \"tags\": [\n {}\n ],\n \"systemPrompt\": \"<string>\",\n \"userPromptTemplate\": \"<string>\",\n \"tone\": \"<string>\",\n \"outputFormat\": \"<string>\",\n \"fewShot\": [\n {}\n ],\n \"context\": {},\n \"isActive\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/admin/prompts/:id/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"section\": \"<string>\",\n \"subSection\": \"<string>\",\n \"route\": \"<string>\",\n \"categories\": [\n {}\n ],\n \"tags\": [\n {}\n ],\n \"systemPrompt\": \"<string>\",\n \"userPromptTemplate\": \"<string>\",\n \"tone\": \"<string>\",\n \"outputFormat\": \"<string>\",\n \"fewShot\": [\n {}\n ],\n \"context\": {},\n \"isActive\": true\n}"
response = http.request(request)
puts response.read_body{
"400": {},
"401": {},
"403": {},
"404": {},
"409": {},
"data": {}
}Updates an existing prompt. A new version snapshot is automatically created on every update, preserving the full change history.
This will update only the
Authentication
Requires JWT Bearer token (Cognito) with admin role.Path Parameters
string
required
Prompt UUID to updateFormat: UUIDExample:
550e8400-e29b-41d4-a716-446655440000Request Body
All fields are optional — only provide the fields you want to update.string
Updated prompt nameMax length: 200
string
Updated agent section assignmentValues:
parser, gap_detector, risk_analysis, report_generationstring
Updated sub-sectionMax length: 100
string
Updated frontend route association
array
Updated list of applicable risk categories
array
Updated tags
string
Updated system prompt
string
Updated user prompt templateSupports variable substitution:
{{category_1}}, {{category_2}}, {{categories}}string
Updated tone instructionsMax length: 500
string
Updated output format instructionsMax length: 5000
array
Updated few-shot examplesEach example has:
input(string, required): Example user inputoutput(string, required): Expected model output
object
Updated context configurationProperties:
persona(string): System persona definitionsources(array): List of reference sourcesconstraints(string): Operational constraintsguardrails(string): Safety guardrails
boolean
Set to true to activate this promptMay deactivate other prompts in the same section to maintain the rule: only one active prompt per section.
Response
object
The updated prompt object with incremented version number
Example Request
curl -X PUT https://api.example.com/api/admin/prompts/550e8400-e29b-41d4-a716-446655440000/update \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Gap Detection — Market Risk v3",
"tags": ["v3", "production", "reviewed"],
"systemPrompt": "You are an expert agricultural risk analyst with 15+ years of experience in CGIAR research programmes. Analyze the provided business plan document and identify gaps in the risk assessment across the specified categories.",
"isActive": true
}'
Example Response
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Gap Detection — Market Risk v3",
"section": "gap_detector",
"subSection": "Market Risk",
"route": "/assessments/:id/gap-detector",
"categories": ["Market Risk"],
"tags": ["v3", "production", "reviewed"],
"version": 3,
"isActive": true,
"systemPrompt": "You are an expert agricultural risk analyst with 15+ years of experience in CGIAR research programmes. Analyze the provided business plan document and identify gaps in the risk assessment across the specified categories.",
"userPromptTemplate": "Given the following business plan section:\n\n{{document_excerpt}}\n\nIdentify gaps in risk coverage for the following categories: {{categories}}",
"tone": "Professional, analytical, concise. Use bullet points for lists.",
"outputFormat": "Return a JSON object with keys: 'gaps' (array of strings), 'severity' (low|medium|high), 'recommendations' (array of strings)",
"fewShot": [
{
"input": "What are the main market risks?",
"output": "The main market risks include price volatility, lack of market access, and limited contract farming opportunities."
}
],
"context": {
"persona": "Expert agricultural risk analyst specializing in CGIAR research.",
"sources": ["CGIAR Research Programs", "FAO Risk Framework"],
"constraints": "Respond only based on the provided document.",
"guardrails": "Do not provide investment advice."
},
"commentsCount": 3,
"createdById": "user-uuid-123",
"updatedById": "user-uuid-456",
"createdAt": "2026-02-20T10:00:00.000Z",
"updatedAt": "2026-03-04T14:30:00.000Z"
}
}
Error Responses
error
Validation error (invalid field values)
error
Missing or invalid Bearer token
error
Forbidden — admin role required
error
Prompt not found
error
Conflict — concurrent update detectedThis occurs when another user updated the prompt between your read and write operations.
Versioning
On every update:- Current prompt state is snapshotted to
prompt_versionstable - Prompt
versionis incremented - Prompt record is updated with new values
- A change record is created in
prompt_changestable with:changeType: UPDATEchangesfield containing field-level diffs (old vs new values)authorId(user who made the change)version(new version number)
Conflict Detection
The update endpoint implements optimistic locking:- If the prompt was modified by another user since you last read it, you’ll receive a
409 Conflicterror - Re-fetch the latest version, review changes, and retry your update
Partial Updates
Only the fields you provide in the request body are updated:{
"tags": ["v3", "reviewed"]
}
tags field, leaving all other fields unchanged.
Source Code
Implementation:packages/api/src/prompts/prompts.controller.ts:159⌘I