Prompts

Template management with versioning, environments, and A/B testing.

Endpoints

MethodPathAuthDescription
POST/v1/promptsAPI KeyCreate a prompt
GET/v1/promptsAPI KeyList all prompts
GET/v1/prompts/:idAPI KeyGet with version history
PUT/v1/prompts/:idAPI KeyUpdate (new version)
DELETE/v1/prompts/:idAPI KeyArchive
POST/v1/prompts/:id/promoteAPI KeyPromote to environment
POST/v1/prompts/:id/testAPI KeyTest-resolve with variables
POST/v1/prompts/:id/abAPI KeyStart/stop A/B test
GET/v1/prompts/:id/abAPI KeyGet A/B results

Create a prompt

curl -X POST https://api.brainstormrouter.com/v1/prompts \
  -H "Authorization: Bearer br_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "id": "support-reply",
    "template": "You are a {{tone}} support agent for {{company}}. {{memory.human}}",
    "variables": {"tone": "friendly", "company": "Acme"},
    "environment": "dev",
    "change_note": "Initial version"
  }'

Request body

FieldTypeRequiredDescription
idstringYesUnique identifier
templatestringYesTemplate with {{variable}} placeholders
variablesobjectNoDefault variable values
environmentstringNodev (default), staging, or prod
change_notestringNoDescription of this version

Update (new version)

PUT creates a new version automatically:

curl -X PUT https://api.brainstormrouter.com/v1/prompts/support-reply \
  -H "Authorization: Bearer br_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "template": "You are a {{tone}} agent for {{company}}. Always be concise.",
    "change_note": "Simplified template"
  }'

Promote to environment

Move a version through dev → staging → prod:

curl -X POST https://api.brainstormrouter.com/v1/prompts/support-reply/promote \
  -H "Authorization: Bearer br_live_..." \
  -H "Content-Type: application/json" \
  -d '{"version": 2, "target_environment": "prod"}'

Test-resolve

Render a template with variables without saving:

curl -X POST https://api.brainstormrouter.com/v1/prompts/support-reply/test \
  -H "Authorization: Bearer br_live_..." \
  -H "Content-Type: application/json" \
  -d '{"variables": {"tone": "professional", "company": "Acme Corp"}}'
{
  "resolved_text": "You are a professional agent for Acme Corp. Always be concise.",
  "template_id": "support-reply",
  "version": 2,
  "is_ab_test": false
}

A/B testing

Start a test

curl -X POST https://api.brainstormrouter.com/v1/prompts/support-reply/ab \
  -H "Authorization: Bearer br_live_..." \
  -H "Content-Type: application/json" \
  -d '{"action": "start", "version_a": 1, "version_b": 2, "split_ratio": 0.5}'

Get results

curl https://api.brainstormrouter.com/v1/prompts/support-reply/ab \
  -H "Authorization: Bearer br_live_..."

Stop a test

curl -X POST https://api.brainstormrouter.com/v1/prompts/support-reply/ab \
  -H "Authorization: Bearer br_live_..." \
  -d '{"action": "stop"}'