> ## Documentation Index
> Fetch the complete documentation index at: https://docs.siftstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage Ad Hoc Rules

## Overview

This guide shows how to create and evaluate **Ad Hoc Rules** in Sift using the REST API. Ad Hoc Rules are ideal for automated workflows, such as CI/CD pipelines, where Rules need to be defined, updated, and evaluated programmatically. The guide covers how to create Ad Hoc Rules via the [BatchUpdateRules](/api-reference/ruleservice/batchupdaterules) endpoint, preview their behavior using [EvaluateRulesPreview](/api-reference/ruleevaluationservice/evaluaterulespreview), and run evaluations that generate Annotations and Reports using [EvaluateRules](/api-reference/ruleevaluationservice/evaluaterules).

Use this guide when you need to automate Rule creation and execution outside the Sift web application, and want to integrate telemetry-based validation directly into your development or testing pipelines.

<Info>
  **Note**

  This guide uses the Sift REST API for all examples. The same functionality is also available through the gRPC API, which supports official client libraries in **Python**, **Go**, and **Rust**.

  * For full message schemas and service definitions, see [gRPC API](/api/reference/protocol-buffers).
  * For client installation details (Python, Go, Rust), see [Quickstart: Connect to the gRPC API with an official Sift client](/api/reference/protocol-buffers#quickstart%3A-connect-to-the-grpc-api-with-an-official-sift-client).
</Info>

## Instructions

### Step 1: Create an Ad Hoc Rule

To create an Ad Hoc Rule, use the [BatchUpdateRules](/api-reference/ruleservice/batchupdaterules) endpoint and set the `isExternal` flag to `true`. This enables a Rule to be created and evaluated ad hoc and simultaneously, which is ideal for a Rule triggered by CI/CD workflows.

<Info>
  **Note**

  Once an Ad Hoc Rule is created, it cannot be edited through the UI or API. Only non-Ad Hoc Rules can be modified.
</Info>

### Step 2: Preview an Ad Hoc Rule

Before evaluating an Ad Hoc Rule, you can preview what Annotations would be generated using the [EvaluateRulesPreview](/api-reference/ruleevaluationservice/evaluaterulespreview) endpoint. This allows you to validate an Ad Hoc Rule's logic without creating a Report or saving any Annotations.

### Step 3: Evaluate an Ad Hoc Rule

To apply an Ad Hoc Rule to a specific Run or Asset, use the [EvaluateRules](/api-reference/ruleevaluationservice/evaluaterules) endpoint. This evaluates the Rule logic, generating a Report and potential Annotations.
