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.

Request Header
Authorization: Bearer bf_a1b2c3d4e5f6...

⚠
The /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
Agent returned HTTP 200 or {"status":"ok"}. Score: 0 or 1.
exact_match
Response JSON deep-equals the exact_match expected behavior. Score: 0 or 1.
contains_keys
Response object contains all required keys. Score is fractional based on how many are present.
keyword_match
Response text contains all expected keywords (case-insensitive). Score is fraction of keywords found.
json_schema
Response matches the specified JSON schema (supports type, required, properties). Score: 0 or 1.
response_quality
Heuristic check: response is non-empty, non-error, and has substance. Score: 1 or 0.3.

Error Responses

All error responses share the same shape.

Error Body
{ "error": "Human-readable message" }
HTTP Status Codes
CodeMeaning
200OK — request succeeded
201Created — resource was created
202Accepted — async work started (cohort runs)
400Bad Request — missing or invalid fields
404Not Found — resource doesn't exist
422Unprocessable — CI gate failed (regressions detected)
500Internal Server Error

CI/CD Gate

POST /api/gate
Auth Synchronous
Run a set of baseline scenarios against an agent endpoint and get a pass/fail verdict synchronously. Returns HTTP 200 when all scenarios pass, HTTP 422 when one or more fail. Use this as your CI/CD quality gate — fail the pipeline on 422.
Request Fields
FieldTypeRequiredDescription
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.
Query param: ?ci=1 returns compact output optimized for CI log readability.
Request Body
{
  "scenario_ids": "all",
  "agent_endpoint": "https://your-agent.example.com/run"
}
Response (200 — Pass)
{
  "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"
}
Response (422 — Fail, compact ?ci=1)
{
  "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
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

POST /api/scenarios
Auth
Create a new baseline scenario.
Request Fields
FieldTypeRequiredDescription
namestringRequiredHuman-readable name.
agent_endpointstringRequiredURL to POST the scenario input to.
inputobjectRequiredJSON payload sent to the agent on each run.
descriptionstringOptionalFree-text description.
gradersarrayOptionalList of grader names. Defaults to ["status_ok"]. See Graders.
expected_behaviorsarrayOptionalExpected behavior objects matched by graders (e.g., keyword lists, exact values).
thresholdnumberOptionalMinimum composite score to pass (0–1). Defaults to 0.8.
Request Body
{
  "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
}
Response (201)
{
  "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
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}'
GET /api/scenarios
Auth
List all scenarios.
Request
# No body required
curl https://baselineforge.polsia.app/api/scenarios \
  -H "Authorization: Bearer bf_..."
Response (200)
{
  "scenarios": [
    {
      "id": "uuid",
      "name": "Greeting flow",
      "threshold": "0.8",
      "created_at": "2026-06-10T07:00:00.000Z"
      // ... full scenario fields
    }
  ]
}
GET /api/scenarios/:id
Auth
Get a single scenario by UUID.
cURL
curl https://baselineforge.polsia.app/api/scenarios/550e8400-... \
  -H "Authorization: Bearer bf_..."
Response (200)
{ "scenario": { "id": "uuid", ... } }
PUT /api/scenarios/:id
Auth
Update a scenario. Pass any subset of scenario fields in the body.
Request Body (partial)
{ "threshold": 0.9, "name": "Updated name" }
Response (200)
{ "scenario": { /* updated fields */ } }
DELETE /api/scenarios/:id
Auth
Delete a scenario permanently.
cURL
curl -X DELETE https://baselineforge.polsia.app/api/scenarios/550e8400-... \
  -H "Authorization: Bearer bf_..."
Response (200)
{ "deleted": true, "id": "uuid" }

Cohort Runs

POST /api/runs
Auth Async
Trigger a cohort run for a scenario. Returns HTTP 202 immediately with a run ID. Execution continues asynchronously — poll GET /api/runs/:id for results. For a synchronous gate-style check, use POST /api/gate instead.
Request Fields
FieldTypeRequiredDescription
scenario_idstringRequiredUUID of the scenario to run.
cohort_sizenumberOptionalNumber of parallel agent calls (1–50, default 1).
cohort_labelstringOptionalFree-text label, e.g. git commit SHA or deploy tag.
Request Body
{
  "scenario_id": "550e8400-e29b-41d4-a716-446655440000",
  "cohort_size": 10,
  "cohort_label": "deploy-v2.4.1"
}
Response (202)
{
  "cohort_run_id": "uuid",
  "status": "running",
  "scenario_id": "uuid"
}
cURL
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"}'
GET /api/runs/:id
Auth
Get the full results of a cohort run, including all individual execution results.
cURL
curl https://baselineforge.polsia.app/api/runs/uuid \
  -H "Authorization: Bearer bf_..."
Response (200)
{
  "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.

POST /api/webhooks
Auth
Create a webhook subscription. Omit scenario_id to subscribe to all scenarios globally.
Request Fields
FieldTypeRequiredDescription
urlstringRequiredHTTPS endpoint to POST events to. Slack webhook URLs are auto-detected.
scenario_idstringOptionalScope to one scenario UUID. Omit for global (all scenarios).
event_typestringOptionalCurrently only "regression_detected".
activebooleanOptionalEnable/disable. Defaults to true.
Request Body
{
  "url": "https://hooks.slack.com/services/T00/B00/xxx",
  "scenario_id": "uuid",
  "event_type": "regression_detected",
  "active": true
}
Response (201)
{
  "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"
  }
}
Webhook Payload (regression_detected)
{
  "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
}
GET /api/webhooks
Auth
List all webhook configs. Filter by scenario with ?scenario_id=uuid.
cURL
curl "https://baselineforge.polsia.app/api/webhooks?scenario_id=uuid" \
  -H "Authorization: Bearer bf_..."

API Keys

POST /api/keys
First request: unauthenticated
Generate a new API key. The plaintext key (format: bf_<64 hex chars>) is returned once — only a bcrypt hash is stored.
⚠
Copy and store your key securely. It cannot be recovered after this response. To rotate, generate a new key and revoke the old one via the Dashboard → API Keys tab.
Request Body
{
  "name": "CI pipeline - GitHub Actions"
}
Response (201)
{
  "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
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

GET /health
No auth
Returns 200 when the service is healthy. Used by Render for uptime monitoring.
cURL
curl https://baselineforge.polsia.app/health
Response (200)
{ "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

✓
Store your API key as a CI secret (BASELINEFORGE_API_KEY). Never commit it to the repository. Generate one at Dashboard → API Keys.