REST /api/v1/scenario-evaluations 7 endpoints
GET /api/v1/scenario-evaluations/api/v1/scenario-evaluations

List past evaluation runs with outcome summaries

Public

Response Example

{
  "data": [
    {
      "id": "eval_f2c9a1",
      "chapter_id": "ch_boston_001",
      "evaluated_at": "2026-03-26T06:00:00Z",
      "activity_id": "act_7e2f9a",
      "rules_evaluated": 12,
      "triggered_count": 2,
      "status": "completed"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 142
  }
}
GET /api/v1/scenario-evaluations/api/v1/scenario-evaluations/:id

Fetch a single evaluation run result with all triggered scenarios

Public

Response Example

{
  "id": "eval_f2c9a1",
  "chapter_id": "ch_boston_001",
  "evaluated_at": "2026-03-26T06:00:00Z",
  "activity_id": "act_7e2f9a",
  "rules_evaluated": 12,
  "triggered_count": 2,
  "triggered_scenarios": [
    {
      "rule_id": "rule_8f3a2c",
      "scenario_id": "missed_activity_3day",
      "user_id": "usr_4bc8d2",
      "scheduled_for": "2026-03-27T06:00:00Z"
    }
  ],
  "status": "completed"
}
POST /api/v1/scenario-evaluations/api/v1/scenario-evaluations

Trigger on-demand rule evaluation for a chapter + activity (maps to evaluateRules)

Public

Request Example

{
  "chapter_id": "ch_boston_001",
  "activity": {
    "id": "act_7e2f9a",
    "user_id": "usr_4bc8d2",
    "activity_type": "run",
    "distance_meters": 5200,
    "duration_seconds": 1860,
    "completed_at": "2026-03-24T07:30:00Z"
  }
}

Response Example

{
  "id": "eval_f2c9a1",
  "chapter_id": "ch_boston_001",
  "evaluated_at": "2026-03-26T09:01:00Z",
  "activity_id": "act_7e2f9a",
  "rules_evaluated": 12,
  "triggered_count": 1,
  "triggered_scenarios": [
    {
      "rule_id": "rule_8f3a2c",
      "scenario_id": "missed_activity_3day",
      "user_id": "usr_4bc8d2",
      "scheduled_for": "2026-03-25T07:30:00Z",
      "prompt_template_id": "tmpl_re_engage_01"
    }
  ],
  "status": "completed"
}
PUT /api/v1/scenario-evaluations/api/v1/scenario-evaluations/:id

Update evaluation run metadata (e.g. mark as archived or reviewed)

Public

Request Example

{
  "status": "archived"
}

Response Example

{
  "id": "eval_f2c9a1",
  "chapter_id": "ch_boston_001",
  "evaluated_at": "2026-03-26T06:00:00Z",
  "status": "archived",
  "updated_at": "2026-03-26T10:30:00Z"
}
DELETE /api/v1/scenario-evaluations/api/v1/scenario-evaluations/:id

Delete an evaluation run record

Public

Response Example

{
  "deleted": true,
  "id": "eval_f2c9a1"
}
GET /api/v1/scenario-evaluations/api/v1/scenario-evaluations/active-rules

Load all currently enabled rules for a chapter (maps to loadActiveRules)

Public

Response Example

{
  "data": [
    {
      "id": "rule_8f3a2c",
      "scenario_id": "missed_activity_3day",
      "trigger_type": "activity_missed",
      "trigger_threshold_days": 3,
      "delay_hours": 24,
      "enabled": true,
      "priority": 1
    },
    {
      "id": "rule_3b9e7d",
      "scenario_id": "low_mileage_week",
      "trigger_type": "below_weekly_target",
      "trigger_threshold_days": 7,
      "delay_hours": 12,
      "enabled": true,
      "priority": 2
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 8
  }
}
POST /api/v1/scenario-evaluations/api/v1/scenario-evaluations/trigger-check

Check whether a single rule matches a given activity (maps to matchesTrigger + isWithinDelayWindow)

Public

Request Example

{
  "rule_id": "rule_8f3a2c",
  "activity": {
    "id": "act_7e2f9a",
    "user_id": "usr_4bc8d2",
    "activity_type": "run",
    "distance_meters": 5200,
    "completed_at": "2026-03-24T07:30:00Z"
  },
  "activity_date": "2026-03-24T07:30:00Z"
}

Response Example

{
  "rule_id": "rule_8f3a2c",
  "matches_trigger": true,
  "within_delay_window": true,
  "should_trigger": true,
  "delay_window_expires_at": "2026-03-25T07:30:00Z"
}

Additional Metadata

{
  "contract_summary": {
    "total_contracts": 410,
    "total_endpoints": 2416,
    "api_styles_used": [
      "rest"
    ]
  },
  "generated_at": "2026-03-26T06:55:53.316Z"
}