API Reference

Prompts

Versioned prompt templates, tagged by environment.

GET/api/prompts

List 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/prompts

Create a new prompt (no versions yet — add one with the endpoint below).

Body fieldTypeRequired
namestringyes
descriptionstringno
tagsstring[]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/:promptId

Get 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/versions

Add a new version. Version numbers increment automatically — you never overwrite one.

Body fieldTypeRequired
templatestringyes
environment"draft" | "staging" | "production"no — defaults to "draft"
modelstringno — 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

FieldTypeNotes
templatestringMustache syntax — see Prompts concept page for rendering
environmentPromptEnvironmentdraft / staging / production
versionnumberAuto-incremented per prompt, starting at 1