Before you begin
- You have a Sift API key and your base URLs.
- You have either the ID of the Run to evaluate the Ad Hoc Rule against, or the IDs of the Assets and the time range to evaluate it over.
How Ad Hoc Rules differ from Rules
An Ad Hoc Rule is a Rule intended for automated workflows such as CI/CD pipelines, where you create and evaluate the Rule in a single pipeline step.- Setting
isExternaltotruewhen you create a Rule marks it as an Ad Hoc Rule instead of a Rule managed through the UI. - Ad Hoc Rules don’t appear in the Rules tab, unlike Rules that aren’t Ad Hoc.
- Because of that, any Report generated from an Ad Hoc Rule displays the Rule’s logic directly, so reviewers can see what was evaluated without looking it up elsewhere.
- Ad Hoc Rules are always immutable once created, since they’re meant to be defined externally in source control and re-applied through your pipeline rather than edited in place. Rules that aren’t Ad Hoc stay editable.
Create an Ad Hoc Rule
Call theBatchUpdateRules endpoint with isExternal set to true. Use assetConfiguration to scope the Rule to the Asset whose Channels the condition references.
annotationType:
ANNOTATION_TYPE_DATA_REVIEWcreates an issue-tracking Annotation with a status workflow, the right choice for most Rule actions like this one. It can be assigned to a user, and starts as Open by default until someone marks it Failed or Accepted during review.ANNOTATION_TYPE_PHASEcreates an informational milestone marker with no status instead, and won’t behave the same way for a condition like this.
Preview an Ad Hoc Rule
Call theEvaluateRulesPreview endpoint to see what Annotations it would generate, without creating a Report or saving any Annotations. Use the Rule ID from the previous step.
curl
Ingestion ordering: If you create a Run, stream Channel data to it, and immediately call
EvaluateRulesPreview, the preview can run before the streamed data finishes processing, causing a “no matching Channels found for Rule” error. To guarantee the Channels are available before evaluation, use a data import instead of streaming. The Channels are available once the import completes.Python: Unlike the Create and Evaluate steps, the official Python client doesn’t yet have a method to preview an Ad Hoc Rule evaluation. Support is coming soon.
Evaluate an Ad Hoc Rule
Call theEvaluateRules endpoint with a Run ID and the Rule ID from the previous step.
Asynchronous processing: It’s common for
EvaluateRules to return a jobId, even when reportId is already set. This means the evaluation is still processing and createdAnnotationCount in this response isn’t final yet. Poll ListJobs with a job_id filter until the job completes to get the actual count.