---
title: "Prepare a rule that researches rows when they first become ready or when their inputs change, with a per-run and a total spending limit. Nothing runs until it's approved."
method: POST
path: "/v1/investigations/rules"
---

# Prepare a rule that researches rows when they first become ready or when their inputs change, with a per-run and a total spending limit. Nothing runs until it's approved.

`POST /v1/investigations/rules`

## Request

- Base URL: `https://api.specstream.ai`
- URL: `https://api.specstream.ai/v1/investigations/rules`
- Auth: API key in header `Authorization`

## Request body

- ResearchRulePrepare
  - `request_id` string, required
  - `name` string, required
  - `collection_id` string, required
  - `function_id` string, required
  - `bindings` object, required
  - `conditions` ResearchRuleCondition[]
    - `field` string, required
    - `operator` 'equals' | 'not_equals' | 'present' | 'empty'
    - `value` union
      - string
      - integer
      - number
      - boolean
  - `trigger` 'first_ready' | 'input_changed'
  - `include_existing` boolean
  - `reuse_completed` boolean
  - `batch_size` integer
  - `per_batch_cents` integer, required
  - `total_cents` integer, required
  - `valid_until` string, date-time, required

## Response `201`

Prepare a rule that researches rows when they first become ready or when their inputs change, with a per-run and a total spending limit. Nothing runs until it's approved.

- object
  - `data` ResearchRuleView, required
    - `rule_id` string, required
    - `name` string, required
    - `collection_id` string, required
    - `function_id` string, required
    - `project_id` string, nullable, required
    - `definition` ResearchRulePrepare, required
      - `request_id` string, required
      - `name` string, required
      - `collection_id` string, required
      - `function_id` string, required
      - `bindings` object, required
      - `conditions` ResearchRuleCondition[]
        - `field` string, required
        - `operator` 'equals' | 'not_equals' | 'present' | 'empty'
        - `value` union
          - string
          - integer
          - number
          - boolean
      - `trigger` 'first_ready' | 'input_changed'
      - `include_existing` boolean
      - `reuse_completed` boolean
      - `batch_size` integer
      - `per_batch_cents` integer, required
      - `total_cents` integer, required
      - `valid_until` string, date-time, required
    - `request` string, required
    - `state` string, required
    - `reason` string, nullable, required
    - `version` integer, required
    - `review_hash` string, required
    - `review_expires_at` string, date-time, required
    - `currency` string, required
    - `committed_maximum_cents` integer, required
    - `remaining_cents` integer, required
    - `last_checked_at` string, date-time, nullable, required
    - `created_at` string, date-time, required
    - `counts` object, required
    - `rows` object[], required
    - `rows_offset` integer, required
    - `next_rows_offset` integer, nullable, required
    - `runs` object[], required
    - `total_runs` integer, required
    - `automatic_execution` boolean
    - `original_deliveries_unchanged` true

## Other responses

- `default`: Error envelope

---

[API](https://skmtc.dev/specstream/apis/specstream-api.md) · [All operations](https://skmtc.dev/specstream/apis/specstream-api/llms.txt) · [OpenAPI document](https://skmtc.dev/specstream/apis/specstream-api/revisions/5a9f51143a13?raw)
