---
title: "Create a data reaction"
method: POST
path: "/v1/projects/{projectId}/reactions"
tags: ["Reactions"]
---

# Create a data reaction

`POST /v1/projects/{projectId}/reactions`

## Request

- Base URL: `https://api.spice.ai`
- URL: `https://api.spice.ai/v1/projects/{projectId}/reactions`
- Auth: HTTP bearer

Creates a Drasi data reaction from a data template. Requires `reactions:write`. Email and HTTP are sinks. Optional `spec.model` transforms the matching query result with a spicepod model that can tool-call back to Cloud to send the configured sink.

## Path parameters

- `projectId` integer, required

## Headers

- `X-Org-Name` string

## Request body

- object
  - `name` string, required: Display name. Unique, case-insensitively, among the project's live monitors and data reactions. A collision answers 409.
  - `description` string
  - `templateId` string, required
  - `spec` object, required: Reaction parameters. Which properties apply is decided by `templateId`. Each property below names the templates that read it, and a property a template does not read is accepted and ignored rather than rejected.
    - `op` 'GT' | 'GEQ' | 'LT' | 'LEQ' | 'EQ' | 'NEQ', required: Comparison operator. Required on every reaction spec.
    - `threshold` number, required: Numeric threshold. Required on every reaction spec. `task_history_slow` compares it against the task duration in milliseconds; `dataset_row_match` and `dataset_query` match on the query itself, so they conventionally send 0.
    - `window` '1m' | '5m' | '15m' | '30m' | '1h': Evaluation window. Only project monitors (`/v1/projects/{projectId}/monitors`) act on it. A data reaction fires on the matching row, so the value is stored and never read.
    - `sustainSecs` integer: How long the condition must hold before firing, in seconds. Like `window`, only project monitors act on it.
    - `severity` 'warn' | 'critical': Severity recorded on each reaction event and carried into the email or webhook notification.
    - `dataset` string: Single dataset to watch. Required by `dataset_row_match` when `conditions` is omitted.
    - `column` string: Column to compare. Required by `dataset_row_match` when `conditions` is omitted.
    - `value` union: Value to compare `column` against. Required by `dataset_row_match` when `conditions` is omitted.
      - string
      - number
    - `datasets` string[]: Datasets the reaction watches. `dataset_row_match` uses this list. Omit it to derive names from `conditions`. `dataset_query` does not read this field.
    - `conditions` object[]: Row-match predicates, read by `dataset_row_match`. CONTAINS, STARTS_WITH, ENDS_WITH, IS_NULL, and IS_NOT_NULL are allowed in addition to equality and ordering. IS_NULL and IS_NOT_NULL omit value.
      - `dataset` string, required
      - `column` string, required
      - `op` 'EQ' | 'NEQ' | 'GT' | 'GEQ' | 'LT' | 'LEQ' | 'CONTAINS' | 'STARTS_WITH' | 'ENDS_WITH' | 'IS_NULL' | 'IS_NOT_NULL', required
      - `value` union: Required except for IS_NULL and IS_NOT_NULL.
        - string
        - number
    - `returnFields` object[]: Dataset fields returned by generated row-match queries. Include identity and all monitored fields.
      - `dataset` string, required
      - `columns` string[], required
    - `queryLanguage` 'cypher' | 'gql': Language of `query`, read by `dataset_query`. Defaults to `gql` when omitted.
    - `query` string: Authored continuous query. Required by `dataset_query`.
    - `includeDetails` boolean: When true, notifications include matching row details. Off by default.
    - `model` object: Optional spicepod model transform (data reactions only). The model can call one tool for each selected sink (send_email, send_webhook, or send_slack).
      - `model` string, required: Spicepod model or worker name
      - `instructions` string, required: System instructions sent with each matching query result
  - `target` union: A notification sink in a create or update request. Cluster monitors, project monitors and data reactions accept the same shape.
    - EmailSinkInput
      - `type` 'email', required
      - `recipientUserIds` integer[]: Organization members to email, by user ID.
      - `emails` string[]
    - HttpSinkInput
      - `type` 'http', required
      - `url` string, uri, required: The URL each notification is sent to, using `method`. Must be https and must resolve to a public address.
      - `method` 'POST' | 'PUT' | 'PATCH': A create that omits it uses POST. An update that omits it keeps the stored method.
      - `token` string: Bearer token sent with each delivery. Stored encrypted and never returned.
    - SlackSinkInput
      - `type` 'slack', required
      - `channelId` string, required: Slack conversation id. The organization must already have Slack connected.
      - `channelName` string
  - `targets` ClusterMonitorTarget[]: Full destination set. When present, this replaces `target` and is the complete list. At most one sink of each type.
    - union: A notification sink in a create or update request. Cluster monitors, project monitors and data reactions accept the same shape.
      - EmailSinkInput
        - `type` 'email', required
        - `recipientUserIds` integer[]: Organization members to email, by user ID.
        - `emails` string[]
      - HttpSinkInput
        - `type` 'http', required
        - `url` string, uri, required: The URL each notification is sent to, using `method`. Must be https and must resolve to a public address.
        - `method` 'POST' | 'PUT' | 'PATCH': A create that omits it uses POST. An update that omits it keeps the stored method.
        - `token` string: Bearer token sent with each delivery. Stored encrypted and never returned.
      - SlackSinkInput
        - `type` 'slack', required
        - `channelId` string, required: Slack conversation id. The organization must already have Slack connected.
        - `channelName` string

## Response `201`

Reaction created

- Reaction: The fields a project monitor and a data reaction share. `Reaction` and `ProjectMonitor` each narrow `kind` and describe their own `spec`.
  - `id` string, uuid, required: Identifier of the monitor or reaction. This is the value the get, update and delete operations take.
  - `org_id` integer, required: Organization that owns the project
  - `app_id` integer, required: Project the monitor or reaction belongs to
  - `created_by` integer, nullable, required: User who created it, when it was created by a user credential
  - `name` string, required: Display name, unique case-insensitively among the project's live monitors and data reactions
  - `description` string, nullable, required
  - `kind` 'data', required: The reactions endpoints only ever return `data`.
  - `status` 'active' | 'disabled', required: Whether it is evaluating
  - `template_id` string, required: Template it was created from
  - `spec` object, required: Reaction parameters, normalized for the response: a reaction whose model transform is still held on `target` is returned with that transform copied into `spec.model`. Which properties are meaningful is decided by `template_id`. The create operation's request body lists the properties each template reads.
  - `target` union, required: A configured sink. An HTTP bearer token is never returned.
    - EmailSinkView
      - `type` 'email', required
      - `recipientUserIds` integer[]
      - `emails` string[]
    - HttpSinkView
      - `type` 'http', required
      - `url` union, required: The sink's URL. An empty string means the stored sink no longer passes validation. Update the sink to replace it.
        - string, uri
        - ''
      - `method` 'POST' | 'PUT' | 'PATCH'
    - SlackSinkView
      - `type` 'slack', required
      - `channelId` union, required: The Slack channel ID. An empty string means the stored sink no longer passes validation. Update the sink to replace it.
        - string
        - ''
      - `channelName` string
  - `targets` ReactionSinkView[], required: Every configured sink, ordered email, then slack, then http. `target` is the first of these. An HTTP sink's token is never returned.
    - union: A configured sink. An HTTP bearer token is never returned.
      - EmailSinkView
        - `type` 'email', required
        - `recipientUserIds` integer[]
        - `emails` string[]
      - HttpSinkView
        - `type` 'http', required
        - `url` union, required: The sink's URL. An empty string means the stored sink no longer passes validation. Update the sink to replace it.
          - string, uri
          - ''
        - `method` 'POST' | 'PUT' | 'PATCH'
      - SlackSinkView
        - `type` 'slack', required
        - `channelId` union, required: The Slack channel ID. An empty string means the stored sink no longer passes validation. Update the sink to replace it.
          - string
          - ''
        - `channelName` string
  - `recipient_user_ids` integer[], required: Organization members emailed when it fires. Empty when there is no email sink, and for an email sink addressed only by `emails`. When a created email sink named no recipients at all, the API stores the creating user.
  - `last_fired_at` string, date-time, nullable, required: When it last fired, or null if it never has
  - `last_resolved_at` string, date-time, nullable, required: When it last resolved, or null if it never has
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `400`: Invalid request body or project ID
- `401`: Unauthorized
- `403`: Insufficient scope
- `404`: Project not found
- `409`: A live monitor or data reaction in this project already has this name
- `413`: Request body too large
- `422`: A required project capability or Slack connection is unavailable
- `500`: Internal server error
- `502`: Failed to provision reaction
- `503`: The project's Drasi data source is starting or unavailable

---

[API](https://skmtc.dev/spice/apis/spice-cloud-control-plane-api.md) - [All operations](https://skmtc.dev/spice/apis/spice-cloud-control-plane-api/llms.txt) - [OpenAPI document](https://skmtc.dev/spice/apis/spice-cloud-control-plane-api/revisions/5f3b75dd847d?raw)
