Prompts
Template management with versioning, environments, and A/B testing.
Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
| POST | /v1/prompts | API Key | Create a prompt |
| GET | /v1/prompts | API Key | List all prompts |
| GET | /v1/prompts/:id | API Key | Get with version history |
| PUT | /v1/prompts/:id | API Key | Update (new version) |
| DELETE | /v1/prompts/:id | API Key | Archive |
| POST | /v1/prompts/:id/promote | API Key | Promote to environment |
| POST | /v1/prompts/:id/test | API Key | Test-resolve with variables |
| POST | /v1/prompts/:id/ab | API Key | Start/stop A/B test |
| GET | /v1/prompts/:id/ab | API Key | Get 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
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Unique identifier |
template | string | Yes | Template with {{variable}} placeholders |
variables | object | No | Default variable values |
environment | string | No | dev (default), staging, or prod |
change_note | string | No | Description 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"}'