---
title: "Backtest"
method: POST
path: "/api/v1/agents/copilot/backtest"
tags: ["agent-copilot"]
---

# Backtest

`POST /api/v1/agents/copilot/backtest`

Replay a not-yet-created config over the trailing window using the live
poll's own decision path. Read-only: the agent is never persisted, nothing
fires. The ``notes`` field carries every honesty caveat — surface it.

## Headers

- `authorization` string, nullable — Bearer <token>

## Request body

- BacktestRequest
  - `config` AgentCreate, required
    - `name` string, required
    - `channel` 'email' | 'push', nullable
    - `trigger_description` string, nullable
    - `trigger_source` 'posthog_event' | 'subscription_event' | 'enrichment' | 'agent_chain' | 'renewal_date' | 'habit_rebuild' | 'habit_maintenance' | 'first_week'
    - `event_name` string, nullable
    - `hogql_query` string, nullable
    - `property_filters` AppSchemasAgentPropertyFilter[]
      - `key` string, required
      - `operator` string, required
      - `value` string, required
      - `type` string, nullable
    - `trigger_clauses` TriggerClause[]
      - `event` string, required
      - `property_filters` AppSchemasAgentPropertyFilter[]
        - `key` string, required
        - `operator` string, required
        - `value` string, required
        - `type` string, nullable
      - `presence` 'did' | 'not_did'
      - `not_delay_days` integer, nullable
    - `trigger_match` 'any' | 'all'
    - `condition_window_days` integer
    - `instructions` string, required
    - `sender_account` string, nullable
    - `sender_display_name` string, nullable
    - `resend_from_email` string, nullable
    - `reply_to` string, nullable
    - `auto_send` boolean
    - `delivery_mode` 'review' | 'auto' | 'slack' | 'discord' | 'resend' | 'autosend' | 'push' | 'info'
    - `autonomy_level` 'off' | 'shadow' | 'live', nullable
    - `info_channel` 'slack' | 'discord', nullable
    - `digest_id` string, uuid, nullable
    - `enrichment_backfill_days` integer
    - `min_confidence` number
    - `enrichment_match_all` boolean
    - `poll_from` string, date-time, nullable
    - `trigger_delay_hours` integer
    - `trigger_delay_minutes` integer
    - `stale_after_hours` integer, required
    - `renewal_offset_days` integer
    - `parent_agent_id` string, uuid, nullable
    - `ignore_list` string[]
    - `review_context_keys` string[]
    - `cooldown_days` integer
    - `daily_cap` integer, nullable
    - `context_mode` 'trigger' | 'activity_window'
    - `context_window_days` integer
    - `activity_gate` GateCondition[]
      - `field` string, required
      - `operator` string, required
      - `value` string, required
    - `copy_mode` 'ai' | 'template'
    - `copy_variants` CopyVariant[]
      - `condition` GateCondition — A predicate on local customer state (see agent_query.GATE_FIELDS).
        - `field` string, required
        - `operator` string, required
        - `value` string, required
      - `subject` string
      - `body` string
      - `format` 'text' | 'html'
    - `enrichment_context_threshold` number
    - `enrichment_instructions` string, nullable
    - `feedback_questions` string, nullable
    - `enabled` boolean
  - `window_days` integer

## Response `200`

Successful Response

- EnvelopeBacktestReport
  - `data` BacktestReport, required — Replay of a config over the trailing window. ``notes`` carries every honesty caveat (truncation, gates not simulated, unmatched events) — the UI and the copilot must surface them, never just the fire count.
    - `window_days` integer, required
    - `supported` boolean
    - `total_candidates` integer
    - `truncated` boolean
    - `would_fire` integer
    - `fires` BacktestFire[]
      - `customer_id` string, required
      - `name` string, nullable
      - `email` string, nullable
      - `event_ts` string, required
      - `scheduled_for` string, nullable
    - `suppressed` object
    - `notes` string[]
  - `meta` Meta
    - `request_id` string
    - `timestamp` string, date-time
    - `total` integer, nullable
    - `truncated` boolean, nullable

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/minro/apis/minro-cs-platform.md) · [All operations](https://skmtc.dev/minro/apis/minro-cs-platform/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/minro/minro-cs-platform/revisions/eb854265cf29/schema)
