---
updatedAt: 2026-02-27T02:36:07.000Z
---

Fetch the complete documentation index at: https://docs.blockdaemon.com/llms.txt. Use this file to discover all available pages before exploring further. Append .md to any documentation page URL to get its markdown version.

# Step 5. Create a Rule

Easily create new rules for event handling and management.

> ❗️ Important Note
>
> Each call incurs a fixed CU charge, plus additional CUs for API operations. See the [Compute Units Usage](https://docs.blockdaemon.com/reference/compute-units-usage-events) page for details.

## Create a Rule

If you have the following items:

* ✅ Webhook target that has undergone a [verification process](https://docs.blockdaemon.com/reference/webhook-verification-process).
* ✅ Variable(s) with values.

, Then you are ready to create a rule to obtain the data you want.

**How it works?**

Any transactions that meet the `conditions` specified in the rule will send events directly to you through the webhook target. This can be done using the **Rules** endpoint.

### Request Payload

```curl
curl --location 'https://svc.blockdaemon.com/streaming/v2/rules' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
    "condition": [
        {
            "variable_type": "address", 
            "variable_id": "3c1c1483-d8e0-4ecb-95a0-1e18a5d03244"
        }
    ],
    "description": "Polkadot mainnet rule",
    "is_active": true,
    "name": "Polkadot mainnet rule",
    "network": "mainnet",
    "protocol": "polkadot",
    "target": "8918a2f1-28d6-4e2f-837b-fb49ec09daaf",
    "condition_type": "match_var"
}'
```

The request body includes the following parameters:

<Table align={[null,null,"left"]}>
  <thead>
    <tr>
      <th>
        Field
      </th>

      <th>
        Required/Optional
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `condition`
      </td>

      <td>
        Required
      </td>

      <td>
        An array that defines the conditions for the rule. You can reference multiple variable types.

        Transactions that meet these conditions are going to the target.
      </td>
    </tr>

    <tr>
      <td>
        `variable_type`
      </td>

      <td>
        Required
      </td>

      <td>
        Type of the variable in the selected protocol.

        You can find it in the  [supported protocols and networks](https://docs.blockdaemon.com/docs/step-1-get-supported-protocols-and-networks) endpoint.
      </td>
    </tr>

    <tr>
      <td>
        `variable_id`
      </td>

      <td>
        Required
      </td>

      <td>
        The variable ID within the condition.

        Please refer to [this page](https://docs.blockdaemon.com/docs/step-3-create-a-variable) to create a new variable.
      </td>
    </tr>

    <tr>
      <td>
        `is_active`
      </td>

      <td>
        Required
      </td>

      <td>
        By default, the value is set to `true` indicating the rule is active. Set to `false` to temporarily halt the rule to generate any data.
      </td>
    </tr>

    <tr>
      <td>
        `name`
      </td>

      <td>
        Required
      </td>

      <td>
        Name of the rule. Each resource should have a unique name.
      </td>
    </tr>

    <tr>
      <td>
        `description`
      </td>

      <td>
        Optional
      </td>

      <td>
        Description of the rule.
      </td>
    </tr>

    <tr>
      <td>
        `network`
      </td>

      <td>
        Required
      </td>

      <td>
        Specifies the network for which the rule should be applied.  
        You can check supported protocols and networks [here](https://docs.blockdaemon.com/docs/step-1-get-supported-protocols-and-networks) .
      </td>
    </tr>

    <tr>
      <td>
        `protocol`
      </td>

      <td>
        Required
      </td>

      <td>
        Specifies the protocol for which the rule should be applied.  
        You can check supported protocols and networks [here](https://docs.blockdaemon.com/docs/step-1-get-supported-protocols-and-networks).
      </td>
    </tr>

    <tr>
      <td>
        `target`
      </td>

      <td>
        Required
      </td>

      <td>
        The target where the rule will be applied to send data.

        Please refer to [this page](https://docs.blockdaemon.com/docs/step-2-create-a-new-target) to create a new target.
      </td>
    </tr>

    <tr>
      <td>
        `template`
      </td>

      <td>
        Optional
      </td>

      <td>
        This is a predefined template other than the [Events Unified Format](https://docs.blockdaemon.com/docs/events-unified-format) . If no template is provided or if you use the `ALL_DATA` value, messages will be delivered in their original form.

        Please refer to [this page](https://docs.blockdaemon.com/docs/advanced-templating)   to create a custom template.
      </td>
    </tr>

    <tr>
      <td>
        `condition_type`
      </td>

      <td>
        Required
      </td>

      <td>
        Type of condition used in the rule, in this case: `match_var`.
      </td>
    </tr>
  </tbody>
</Table>

### Response Payload

A successful request will return the output below.

```json
{
    "condition": [
        {
            "variable_id": "3c1c1483-d8e0-4ecb-95a0-1e18a5d03244",
            "variable_type": "address"
        }
    ],
    "condition_type": "match_var",
    "created_at": "2024-03-06T14:57:10.019668Z",
    "description": "Polkadot mainnet rule",
    "id": "9e2a6c91-18b1-42a4-864b-b3c4efaa5397",
    "is_active": true,
    "name": "Polkadot mainnet rule",
    "network": "mainnet",
    "protocol": "polkadot",
    "target": "8918a2f1-28d6-4e2f-837b-fb49ec09daaf",
    "template": "ALL_DATA",
    "type": "all",
    "updated_at": "2024-03-06T14:57:10.019668Z"
}
```

It includes the following details:

<Table align={[null,"left"]}>
  <thead>
    <tr>
      <th>
        Field
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `condition`
      </td>

      <td>
        An array of the conditions for the rule. Each element is a JSON object referencing a `variable_id` and `variable_type`. This array specifies the events to receive based on the variable types and their corresponding IDs.

        For example:

        * Events where the `address` matches the values of the variable with ID `3c1c1483-d8e0-4ecb-95a0-1e18a5d03244` will trigger either a `confirmed_tx` or a `confirmed_balance`.
        * Events where the `event_type` matches the values of the variable with ID `809f936f-21bb-46a9-bab7-fba90b23b10f` will trigger a block event.
      </td>
    </tr>

    <tr>
      <td>
        `variable_type`
      </td>

      <td>
        Type of the variable in the selected protocol.

        You can find it in the  [supported protocols and networks](https://docs.blockdaemon.com/docs/step-1-get-supported-protocols-and-networks)  endpoint.
      </td>
    </tr>

    <tr>
      <td>
        `variable_id`
      </td>

      <td>
        The variable ID within the condition.

        Please refer to [this page](https://docs.blockdaemon.com/docs/step-3-create-a-variable)  to create a new variable.
      </td>
    </tr>

    <tr>
      <td>
        `is_active`
      </td>

      <td>
        By default, the value is set to `true` indicating the rule is active. Set to `false` to temporarily halt the rule to generate any data.
      </td>
    </tr>

    <tr>
      <td>
        `name`
      </td>

      <td>
        Name of the rule. Each resource should have a unique name.
      </td>
    </tr>

    <tr>
      <td>
        `description`
      </td>

      <td>
        Description of the rule.
      </td>
    </tr>

    <tr>
      <td>
        `network`
      </td>

      <td>
        Specifies the network for which the rule should be applied.
      </td>
    </tr>

    <tr>
      <td>
        `protocol`
      </td>

      <td>
        Specifies the protocol for which the rule should be applied.
      </td>
    </tr>

    <tr>
      <td>
        `target`
      </td>

      <td>
        The target where the rule will be applied to send data.

        Please refer to [this page](https://docs.blockdaemon.com/docs/step-2-create-a-new-target)  to create a new target.
      </td>
    </tr>

    <tr>
      <td>
        `template`
      </td>

      <td>
        This is a predefined template other than the [Events Unified Format](https://docs.blockdaemon.com/docs/events-unified-format). If no template is provided or if you use the `ALL_DATA` value, messages will be delivered in their original form.

        Please refer to [this page](https://docs.blockdaemon.com/docs/advanced-templating)  to create a custom template.
      </td>
    </tr>

    <tr>
      <td>
        `condition_type`
      </td>

      <td>
        Type of condition used in the rule, in this case: `match_var`.
      </td>
    </tr>
  </tbody>
</Table>

<br />

***

## Managing Rule

### [Update a Rule](https://docs.blockdaemon.com/reference/update-rule)

Update an existing rule by replacing it with a new configuration.

> 🚧 Note
>
> A rule must include the chain **protocol and network** to specify the data to stream, one or more **variable-based conditions**\*\* to filter relevant events, a **target ID** that determines where the matched data will be sent, and a **template** that defines the structure of the streamed payload.

**Example Payload**

```curl Request Payload
curl --request PUT \
     --url https://svc.blockdaemon.com/streaming/v2/rules/{RULE_ID} \
     --header 'accept: application/json' \
     --header 'authorization: Bearer YOUR_API_KEY' \
     --header 'content-type: application/json' \
     --data '
{
  "name": "Ethereum mainnet demo",
  "description": "Ethereum mainnet demo",
  "protocol": "ethereum",
  "network": "mainnet",
  "type": "all",
  "isActive": true,
  "condition_type": "match_var",
  "condition": [
    {
      "variable_type": "source-address",
      "variable_id": "<VARIABLE_ID>"
    },
    {
      "variable_type": "destination-address",
      "variable_id": "<VARIABLE_ID>"
    }
  ],
  "target": "<TARGET_ID>",
  "template": "ALL_DATA",
  "id": "<RULE_ID>",
  "created_at": "2024-02-05T13:29:23.2179Z"
}
'
```
```json Response Payload
{
    "condition": [
        {
            "variable_id": "<VARIABLE_ID>",
            "variable_type": "source-address"
        },
        {
            "variable_id": "<VARIABLE_ID>",
            "variable_type": "destination-address"
        }
    ],
    "condition_type": "match_var",
    "created_at": "2024-02-05T13:29:23.2179Z",
    "description": "Updated desc Ethereum mainnet demo",
    "id": "<RULE_ID>",
    "isActive": true,
    "name": "Ethereum mainnet demo",
    "network": "mainnet",
    "protocol": "ethereum",
    "target": "<TARGET_ID>",
    "template": "ALL_DATA",
    "type": "all",
    "updated_at": "2024-02-05T13:41:12.271366Z"
}
```

***

## [Delete a Rule](https://docs.blockdaemon.com/reference/delete-rule)

Delete a rule by its ID and **this action can't be undone**, as it stops all event delivery.

**Example Payload**

```curl Request Payload
curl --request DELETE \
     --url https://svc.blockdaemon.com/streaming/v2/rules/{RULE_ID} \
     --header 'accept: application/json' \
     --header 'authorization: Bearer YOUR_API_KEY'
```
```Text Response Payload
The status code "204 - No Content" indicates that the request was successful and the rule was deleted.
```

<br />

## 👋 Need Help?

Contact us through [email](mailto:support@blockdaemon.com) or our [support page](https://www.blockdaemon.com/support) for any issues, bugs, or assistance you may need.