Overview
The Prompts Management API provides CRUD operations for managing AI prompts used throughout the Alliance IGAD Innovation Hub platform. Prompts control how AI models generate content for proposals, newsletters, and other features. Base URL:/api/admin/prompts
Authentication: All endpoints require admin authentication via JWT Bearer token.
Prompt Schema
Prompts follow a structured schema with the following key fields:| Field | Type | Description |
|---|---|---|
id | string | Unique prompt identifier (UUID) |
name | string | Display name for the prompt (1-200 chars) |
section | enum | Main section (e.g., proposal_writer, newsletter_generator) |
sub_section | string | Sub-section identifier (e.g., step-1, step-2) |
route | string | Optional route identifier for organizing prompts |
categories | string[] | Categories where this prompt applies |
tags | string[] | Tags for filtering and organization |
system_prompt | string | System-level instructions for the AI model |
user_prompt_template | string | User-facing prompt template with placeholders |
version | integer | Version number (starts at 1) |
is_active | boolean | Whether the prompt is active and available for use |
tone | string | Desired output tone (e.g., “Professional and informative”) |
output_format | string | Expected output format description |
created_by | string | Email of user who created the prompt |
updated_by | string | Email of user who last updated the prompt |
created_at | datetime | ISO 8601 timestamp |
updated_at | datetime | ISO 8601 timestamp |
comments_count | integer | Number of comments on this prompt |
Prompt Sections
Available sections (fromProposalSection enum):
proposal_writer- Main proposal generation featurenewsletter_generator- Newsletter generation feature- Legacy sections:
problem_statement,objectives,methodology,budget, etc.
Template Placeholders
Prompt templates support two placeholder formats:- Double curly braces:
{{VARIABLE_NAME}} - Curly + square brackets:
{[VARIABLE_NAME]}
Endpoints
List Prompts
| Parameter | Type | Description |
|---|---|---|
section | ProposalSection | Filter by section |
sub_section | string | Filter by sub-section |
tag | string | Filter by tag |
search | string | Search in name, prompts, route, and tags |
route | string | Filter by route |
is_active | boolean | Filter by active status |
limit | integer | Results per page (1-100, default: 20) |
offset | integer | Pagination offset (default: 0) |
Get Prompt
prompt_id(string, required) - Prompt UUID
version(string, optional) - Version number or “latest” (default: latest)
404- Prompt not found400- Invalid version format
Create Prompt
201 Created
400- Validation error or duplicate active prompt for same section/route/subsection/categories401- Unauthorized (invalid or missing token)
sectionroutesub_sectioncategories(as a set)
Update Prompt
prompt_id(string, required) - Prompt UUID
404- Prompt not found400- Validation error or duplicate active prompt conflict
Delete Prompt
prompt_id(string, required) - Prompt UUID
version(integer, optional) - Specific version to delete. If omitted, deletes all versions.
404- Prompt not found500- Deletion failed
Toggle Active Status
prompt_id(string, required) - Prompt UUID
404- Prompt not found400- Cannot activate due to conflict with another active prompt
Version Control
Prompts use a simple versioning system:- Creation: New prompts start at version 1
- Updates: Updates modify the existing version in-place (not creating new versions)
- History: All changes are tracked in the change history
Change History
create- Initial prompt creationupdate- Content or metadata updateactivate- Prompt activateddeactivate- Prompt deactivated
Comments
Add Comment
Get Comments
Preview Prompt
Authentication
All admin endpoints require authentication:is_admin: true). Tokens are obtained through the authentication endpoints.
Error Responses:
401 Unauthorized- Missing or invalid token403 Forbidden- Valid token but insufficient privileges (not an admin)
Error Handling
All endpoints follow consistent error response format:200 OK- Successful GET/PUT request201 Created- Successful POST (creation)400 Bad Request- Validation error or business logic violation401 Unauthorized- Authentication required or failed403 Forbidden- Insufficient permissions404 Not Found- Resource not found500 Internal Server Error- Server-side error
Rate Limiting
No rate limiting is currently enforced on admin endpoints, but it is recommended to implement reasonable request frequencies to avoid overwhelming the system.Best Practices
- Prompt Naming: Use clear, descriptive names that indicate the prompt’s purpose
- Versioning: Use the
change_commentfield when updating prompts to document changes - Testing: Always use the preview endpoint to test prompts before activating them
- Active Status: Only one prompt should be active per section/route/subsection/categories combination
- Categories: Use consistent category names across related prompts
- Placeholders: Document required variables in the prompt name or comments
- History: Review change history before making significant updates