Developer Reference
API Documentation
Everything you need to integrate BaselineForge into your CI/CD pipeline.
All endpoints accept and return JSON. Bearer token authentication is required on all /api/* routes.
Authentication
Every /api/* request must include a Bearer token.
Generate a key via POST /api/keys.
Keys are shown once on creation — store them securely.
Authorization: Bearer bf_a1b2c3d4e5f6...
/health endpoint is public and does not require authentication.Graders
Graders evaluate your agent's response for each scenario.
Specify an array of grader strings when creating a scenario.
The composite score is the unweighted average across all graders. A run passes when composite_score ≥ threshold.
{"status":"ok"}. Score: 0 or 1.exact_match expected behavior. Score: 0 or 1.Error Responses
All error responses share the same shape.
{ "error": "Human-readable message" }
| Code | Meaning |
|---|---|
| 200 | OK — request succeeded |
| 201 | Created — resource was created |
| 202 | Accepted — async work started (cohort runs) |
| 400 | Bad Request — missing or invalid fields |
| 404 | Not Found — resource doesn't exist |
| 422 | Unprocessable — CI gate failed (regressions detected) |
| 500 | Internal Server Error |
CI/CD Gate
| Field | Type | Required | Description |
|---|---|---|---|
| scenario_ids | string | array | Required | "all" to run every scenario, or an array of scenario UUIDs. |
| agent_endpoint | string | Required | The URL of the agent to test. Receives POST with each scenario's input JSON. |
?ci=1 returns compact output optimized for CI log readability.
{
"scenario_ids": "all",
"agent_endpoint": "https://your-agent.example.com/run"
}
{
"passed": true,
"summary": {
"total": 3,
"passed": 3,
"failed": 0,
"duration_ms": 1842
},
"results": [
{
"scenario_id": "uuid",
"scenario_name": "Greeting flow",
"passed": true,
"composite_score": 0.95,
"threshold": 0.8,
"scores": { "status_ok": 1, "keyword_match": 0.9 },
"duration_ms": 612,
"error": null
}
],
"agent_endpoint": "https://your-agent.example.com/run"
}
{
"passed": false,
"total": 3,
"passed_count": 2,
"failed_count": 1,
"duration_ms": 1250,
"failures": [
{
"scenario_id": "uuid",
"name": "Edge case: empty input",
"score": 0.62,
"threshold": 0.8,
"error": null
}
]
}
curl -X POST https://baselineforge.polsia.app/api/gate?ci=1 \ -H "Authorization: Bearer bf_..." \ -H "Content-Type: application/json" \ -d '{"scenario_ids":"all","agent_endpoint":"https://your-agent.example.com/run"}'
Scenarios
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Required | Human-readable name. |
| agent_endpoint | string | Required | URL to POST the scenario input to. |
| input | object | Required | JSON payload sent to the agent on each run. |
| description | string | Optional | Free-text description. |
| graders | array | Optional | List of grader names. Defaults to ["status_ok"]. See Graders. |
| expected_behaviors | array | Optional | Expected behavior objects matched by graders (e.g., keyword lists, exact values). |
| threshold | number | Optional | Minimum composite score to pass (0–1). Defaults to 0.8. |
{
"name": "Greeting flow",
"description": "Agent greets user by name",
"agent_endpoint": "https://your-agent.example.com/run",
"input": { "user": "Alice", "action": "greet" },
"graders": ["status_ok", "keyword_match"],
"expected_behaviors": [
{ "type": "keyword_match", "keywords": ["Alice", "hello"] }
],
"threshold": 0.8
}
{
"scenario": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Greeting flow",
"description": "Agent greets user by name",
"agent_endpoint": "https://your-agent.example.com/run",
"input": { "user": "Alice", "action": "greet" },
"graders": ["status_ok", "keyword_match"],
"expected_behaviors": [ ... ],
"threshold": "0.8",
"created_at": "2026-06-10T07:00:00.000Z"
}
}
curl -X POST https://baselineforge.polsia.app/api/scenarios \ -H "Authorization: Bearer bf_..." \ -H "Content-Type: application/json" \ -d '{"name":"Greeting flow","agent_endpoint":"https://your-agent.example.com/run","input":{"user":"Alice"},"graders":["status_ok","keyword_match"],"expected_behaviors":[{"type":"keyword_match","keywords":["Alice","hello"]}],"threshold":0.8}'
# No body required curl https://baselineforge.polsia.app/api/scenarios \ -H "Authorization: Bearer bf_..."
{
"scenarios": [
{
"id": "uuid",
"name": "Greeting flow",
"threshold": "0.8",
"created_at": "2026-06-10T07:00:00.000Z"
// ... full scenario fields
}
]
}
curl https://baselineforge.polsia.app/api/scenarios/550e8400-... \
-H "Authorization: Bearer bf_..."
{ "scenario": { "id": "uuid", ... } }
{ "threshold": 0.9, "name": "Updated name" }
{ "scenario": { /* updated fields */ } }
curl -X DELETE https://baselineforge.polsia.app/api/scenarios/550e8400-... \
-H "Authorization: Bearer bf_..."
{ "deleted": true, "id": "uuid" }
?limit=N (max 100, default 30)
curl "https://baselineforge.polsia.app/api/runs/trends/uuid?limit=30" \
-H "Authorization: Bearer bf_..."
{
"trend": [
{
"run_id": "uuid",
"completed_at": "2026-06-10T07:00:00.000Z",
"composite_score": 0.92,
"pass_rate": 1.0,
"status": "passed"
}
]
}
Cohort Runs
| Field | Type | Required | Description |
|---|---|---|---|
| scenario_id | string | Required | UUID of the scenario to run. |
| cohort_size | number | Optional | Number of parallel agent calls (1–50, default 1). |
| cohort_label | string | Optional | Free-text label, e.g. git commit SHA or deploy tag. |
{
"scenario_id": "550e8400-e29b-41d4-a716-446655440000",
"cohort_size": 10,
"cohort_label": "deploy-v2.4.1"
}
{
"cohort_run_id": "uuid",
"status": "running",
"scenario_id": "uuid"
}
curl -X POST https://baselineforge.polsia.app/api/runs \ -H "Authorization: Bearer bf_..." \ -H "Content-Type: application/json" \ -d '{"scenario_id":"uuid","cohort_size":5,"cohort_label":"v2.4.1"}'
curl https://baselineforge.polsia.app/api/runs/uuid \
-H "Authorization: Bearer bf_..."
{
"run": {
"id": "uuid",
"scenario_id": "uuid",
"status": "passed",
"cohort_label": "deploy-v2.4.1",
"started_at": "2026-06-10T07:00:00.000Z",
"completed_at": "2026-06-10T07:00:08.000Z",
"results": [
{
"id": "uuid",
"pass": true,
"composite_score": 0.95,
"scores": { "status_ok": 1, "keyword_match": 0.9 },
"duration_ms": 612,
"error_message": null
}
]
}
}
Webhooks
Webhooks fire a regression_detected event via HTTP POST to your URL
when a cohort run fails to meet the threshold. Slack incoming webhook URLs are auto-detected and formatted
with a rich message block. Delivery is retried up to 3 times on failure.
scenario_id to subscribe to all scenarios globally.| Field | Type | Required | Description |
|---|---|---|---|
| url | string | Required | HTTPS endpoint to POST events to. Slack webhook URLs are auto-detected. |
| scenario_id | string | Optional | Scope to one scenario UUID. Omit for global (all scenarios). |
| event_type | string | Optional | Currently only "regression_detected". |
| active | boolean | Optional | Enable/disable. Defaults to true. |
{
"url": "https://hooks.slack.com/services/T00/B00/xxx",
"scenario_id": "uuid",
"event_type": "regression_detected",
"active": true
}
{
"webhook": {
"id": "uuid",
"url": "https://hooks.slack.com/...",
"scenario_id": "uuid",
"event_type": "regression_detected",
"active": true,
"created_at": "2026-06-10T07:00:00.000Z"
}
}
{
"event": "regression_detected",
"scenario_id": "uuid",
"scenario_name": "Greeting flow",
"run_id": "uuid",
"composite_score": 0.62,
"threshold": 0.8,
"delta": -0.18,
"failed_count": 3,
"total_executions": 10
}
?scenario_id=uuid.curl "https://baselineforge.polsia.app/api/webhooks?scenario_id=uuid" \
-H "Authorization: Bearer bf_..."
API Keys
bf_<64 hex chars>)
is returned once — only a bcrypt hash is stored.
{
"name": "CI pipeline - GitHub Actions"
}
{
"key": "bf_a1b2c3d4e5f6...",
"id": "uuid",
"name": "CI pipeline - GitHub Actions",
"created_at": "2026-06-10T07:00:00.000Z",
"note": "Copy this key now — it will not be shown again."
}
curl -X POST https://baselineforge.polsia.app/api/keys \ -H "Authorization: Bearer bf_..." \ -H "Content-Type: application/json" \ -d '{"name":"CI pipeline - GitHub Actions"}'
Health Check
curl https://baselineforge.polsia.app/health
{ "status": "healthy" }
CI Integration Snippets
Drop these into your pipeline to block deploys when your agent regresses. The gate returns HTTP 422 on failure — most CI systems treat any non-200 as a build failure.
# .github/workflows/quality-gate.yml name: BaselineForge Quality Gate on: push: branches: [main] pull_request: branches: [main] jobs: quality-gate: runs-on: ubuntu-latest steps: - name: Run BaselineForge CI Gate run: | RESULT=$(curl -s -o /dev/null -w "%{http_code}" \ -X POST https://baselineforge.polsia.app/api/gate?ci=1 \ -H "Authorization: Bearer ${{ secrets.BASELINEFORGE_API_KEY }}" \ -H "Content-Type: application/json" \ -d '{"scenario_ids":"all","agent_endpoint":"${{ secrets.AGENT_ENDPOINT }}"}') echo "Gate status: $RESULT" [ "$RESULT" = "200" ] || exit 1
# .gitlab-ci.yml quality-gate: stage: test image: curlimages/curl:latest script: - | RESULT=$(curl -s -o /dev/null -w "%{http_code}" \ -X POST https://baselineforge.polsia.app/api/gate?ci=1 \ -H "Authorization: Bearer $BASELINEFORGE_API_KEY" \ -H "Content-Type: application/json" \ -d "{\"scenario_ids\":\"all\",\"agent_endpoint\":\"$AGENT_ENDPOINT\"}") echo "Gate HTTP status: $RESULT" [ "$RESULT" = "200" ] || (echo "Quality gate FAILED" && exit 1) rules: - if: $CI_COMMIT_BRANCH == "main" - if: $CI_PIPELINE_SOURCE == "merge_request_event"
#!/usr/bin/env bash # run-quality-gate.sh API_KEY="${BASELINEFORGE_API_KEY:?BASELINEFORGE_API_KEY not set}" AGENT_URL="${AGENT_ENDPOINT:?AGENT_ENDPOINT not set}" echo "→ Running BaselineForge quality gate..." RESPONSE=$(curl -s -w "\n%{http_code}" \ -X POST "https://baselineforge.polsia.app/api/gate?ci=1" \ -H "Authorization: Bearer ${API_KEY}" \ -H "Content-Type: application/json" \ -d "{\"scenario_ids\":\"all\",\"agent_endpoint\":\"${AGENT_URL}\"}") HTTP_STATUS=$(echo "$RESPONSE" | tail -1) BODY=$(echo "$RESPONSE" | head -n -1) echo "$BODY" if [ "$HTTP_STATUS" = "200" ]; then echo "✓ Quality gate passed" exit 0 else echo "✗ Quality gate FAILED (HTTP ${HTTP_STATUS})" exit 1 fi
BASELINEFORGE_API_KEY). Never commit it to the repository. Generate one at Dashboard → API Keys.