API Reference
Prompts
Versioned prompt templates, tagged by environment.
GET
/api/promptsList prompts with a computed version count and the latest production version, if any.
{
"prompts": [
{
"id": "prompt_001",
"name": "Support Answer Assistant",
"description": "Answers customer support questions using retrieved context.",
"tags": ["support", "rag"],
"createdAt": "2026-06-07T22:22:00.000Z",
"versionCount": 3,
"latestProductionVersion": {
"id": "pv_003",
"version": 3,
"environment": "production",
"model": "gpt-4o"
}
}
]
}POST
/api/promptsCreate a new prompt (no versions yet — add one with the endpoint below).
| Body field | Type | Required |
|---|---|---|
| name | string | yes |
| description | string | no |
| tags | string[] | no — defaults to [] |
curl -X POST https://preview.devx-ai.xyz/api/prompts \
-H "Content-Type: application/json" \
-d '{ "name": "Ticket Triage", "description": "Classifies incoming tickets by urgency." }'Returns 201 with { prompt }. 400 if name is missing.
GET
/api/prompts/:promptIdGet a prompt with its full version history, newest version first.
{
"prompt": { "id": "prompt_001", "name": "Support Answer Assistant" },
"versions": [
{
"id": "pv_003",
"promptId": "prompt_001",
"version": 3,
"template": "You are a helpful, concise support agent... Context: {{context}}\nQuestion: {{question}}",
"environment": "production",
"model": "gpt-4o",
"createdAt": "2026-07-09T22:22:00.000Z"
}
]
}404 if promptId doesn't match any prompt.
POST
/api/prompts/:promptId/versionsAdd a new version. Version numbers increment automatically — you never overwrite one.
| Body field | Type | Required |
|---|---|---|
| template | string | yes |
| environment | "draft" | "staging" | "production" | no — defaults to "draft" |
| model | string | no — defaults to "gpt-4o-mini" |
curl -X POST https://preview.devx-ai.xyz/api/prompts/prompt_001/versions \
-H "Content-Type: application/json" \
-d '{
"template": "Context: {{context}}\nQuestion: {{question}}\nAnswer in one sentence.",
"environment": "staging",
"model": "gpt-4o"
}'Returns 201 with { version }. 400 if template is missing. 404 if the prompt doesn't exist.
Data model
| Field | Type | Notes |
|---|---|---|
| template | string | Mustache syntax — see Prompts concept page for rendering |
| environment | PromptEnvironment | draft / staging / production |
| version | number | Auto-incremented per prompt, starting at 1 |