---
title: "removeUsedByReference"
method: DELETE
path: "/v1/validation-rules/{ruleId}/used-by"
tags: ["Validation Rules"]
---

# removeUsedByReference

`DELETE /v1/validation-rules/{ruleId}/used-by`

Removes a specific `used_by` reference from an existing validation rule.

Use this endpoint when detaching a validation rule from a journey block or entity attribute.

## Path parameters

- `ruleId` string, required

## Request body

- UsedBy — Describes where and how a validation rule is applied. Used to track associations between rules and the journeys or entity schemas that reference them.
  - `type` 'journey' | 'entity', required — The context in which the rule is used - either a journey block or an entity schema attribute.
  - `schema_slug` string — Slug of the entity schema using this rule. Only applicable when `type` is `entity`.
  - `source_id` string — Unique identifier of the source (e.g. journey ID or entity attribute key) that references this rule.

## Response `200`

Success

- ValidationRule — The Validation rule definition.
  - `title` string, required — Title of the validation rule.
  - `placeholder` string — Placeholder for the validation rule.
  - `used_by` UsedBy[] — Describes where and how a validation rule is applied.
    - `type` 'journey' | 'entity', required — The context in which the rule is used - either a journey block or an entity schema attribute.
    - `schema_slug` string — Slug of the entity schema using this rule. Only applicable when `type` is `entity`.
    - `source_id` string — Unique identifier of the source (e.g. journey ID or entity attribute key) that references this rule.
  - `rule` union
    - RegexRuleType — Validation rule that uses a regular expression to validate input.
      - `type` 'regex', required — Indicates this is a regex-based validation rule.
      - `conditions` union, required — Condition definition for a regex-based validation rule (2 levels deep)
        - object — All conditions must be true (AND logic)
          - `all` union[], required
            - union
              - …
        - object — Any conditions must be true (OR logic)
          - `any` union[], required
            - union
              - …
        - object — NOT condition (negation)
          - `not` union, required
            - RegexFactCondition — Fact-based condition for regex validation
              - …
            - union — Nested condition with logical operators (level 2 only)
              - …
    - PatternRuleType — Validation rule that uses a sequence of patterns to validate input.
      - `type` 'pattern', required — Indicates this is a pattern-based validation rule.
      - `conditions` union, required — Condition definition for a pattern-based validation rule (2 levels deep)
        - object — All conditions must be true (AND logic)
          - `all` union[], required
            - union
              - …
        - object — Any conditions must be true (OR logic)
          - `any` union[], required
            - union
              - …
        - object — NOT condition (negation)
          - `not` union, required
            - union — Fact-based condition for pattern validation
              - …
            - union — Nested condition with logical operators (level 2 only)
              - …
    - NumericRuleType — Validation rule for numeric values, supporting range and digit count constraints.
      - `type` 'numeric', required — Indicates this is a numeric-based validation rule.
      - `conditions` union, required — Condition definition for a numeric-based validation rule (2 levels deep)
        - object — All conditions must be true (AND logic)
          - `all` union[], required
            - union
              - …
        - object — Any conditions must be true (OR logic)
          - `any` union[], required
            - union
              - …
        - object — NOT condition (negation)
          - `not` union, required
            - union — Fact-based condition for numeric validation
              - …
            - union — Nested condition with logical operators (level 2 only)
              - …
    - ComparisonRuleType — Declarative validation rule (schema version v2). Supports predefined comparison operators over number, date and text inputs, with static, dynamic (context path) and relative-date comparison values.
      - `input_type` 'number' | 'date' | 'text', required — The kind of input value the rule validates. Determines which operators are allowed.
      - `conditions` Condition[], required — The comparisons the input value must satisfy. All blocking conditions must pass for the input to be valid; `allow_failure` conditions are advisory and excluded from the verdict. Must contain at least one condition (enforced at write time).
        - `id` string, required — Stable identifier of the condition within the rule, used for editing and error reporting.
        - `operator` 'equal' | 'notEqual' | 'greaterThan' | 'greaterThanInclusive' | 'lessThan' | 'lessThanInclusive' | 'between' | 'dateBefore' | 'dateOnOrBefore' | 'dateAfter' | 'dateOnOrAfter' | 'dateBetween' | 'notInFuture' | 'notInPast' | 'contains' | 'doesNotContain' | 'startsWith' | 'endsWith' | 'regexMatch' | 'lengthBetween' | 'maxDigits' | 'maxDecimals', required — Predefined comparison operator. Compatibility (enforced at write time): - number: equal, notEqual, greaterThan, greaterThanInclusive, lessThan, lessThanInclusive, between, regexMatch, maxDigits, maxDecimals - date: dateBefore, dateOnOrBefore, dateAfter, dateOnOrAfter, dateBetween, notInFuture, notInPast, regexMatch - text: equal, notEqual, contains, doesNotContain, startsWith, endsWith, regexMatch, lengthBetween, greaterThan, greaterThanInclusive, lessThan, lessThanInclusive, between, maxDigits, maxDecimals Range operators (between, dateBetween, lengthBetween) require a `range` value; unary operators (notInFuture, notInPast) require a `none` value; all others require a scalar value. regexMatch validates the raw input string's format and always takes a static string pattern. Numeric comparison operators on text rules parse the input as a number at evaluation time (free-text fields often hold numbers); unparsable input fails the condition. maxDigits limits how many digits the written input may contain in total (grouping separators, sign and the decimal separator are not counted); maxDecimals limits how many digits may follow the decimal separator. Both take a non-negative integer comparison value and, like the other numeric operators, are also allowed on text rules.
        - `value` union, required — The comparison value of a condition - a scalar, a range of scalars, or nothing (unary operators).
          - StaticValue — A fixed comparison value.
            - `source` 'static', required
            - `data` union, required — The literal value. Numbers for numeric comparisons, ISO 8601 date strings for date comparisons, strings for text comparisons.
              - …
          - ContextValue — A dynamic comparison value resolved from runtime context, e.g. `contract.installment_amount` or `previous_reading.value`. The first path segment must match the `name` of a declared context requirement.
            - `source` 'context', required
            - `path` string, required — Dot-separated path into the resolved context.
            - `adjust` ValueAdjustment — Adjusts a context-resolved numeric value before comparison, e.g. "context value plus 10 percent". Used to express tolerance bands such as "at most 10% above the current instalment amount".
              - …
          - RelativeDateValue — A date relative to the evaluation moment, e.g. "today minus 30 days". Only valid for date rules.
            - `source` 'relative_date', required
            - `offset` integer, required — Offset from the anchor. Negative values are in the past, positive in the future, 0 is the anchor itself.
            - `unit` 'days' | 'months' | 'years', required
            - `anchor` 'today'
          - RangeValue — A lower and upper bound for range operators (between, dateBetween, lengthBetween). Bounds are inclusive.
            - `source` 'range', required
            - `min` union, required — A single comparison value - static, resolved from context, or a relative date.
              - …
            - `max` union, required — A single comparison value - static, resolved from context, or a relative date.
              - …
          - NoValue — No comparison value - used by unary operators such as notInFuture / notInPast.
            - `source` 'none', required
        - `error_message` string, required — Message shown to the end user when this condition fails.
        - `applies_when` AppliesWhen — Optional precondition on a condition: the condition only takes part in the validation when this comparison over context holds. Examples: apply the dual-tariff reference only when `contract.htnt` is not empty, or run a plausibility check only when a context value reaches a threshold.
          - `path` string, required — Dot-separated context path whose first segment must match a declared context schema.
          - `operator` 'equal' | 'notEqual' | 'greaterThan' | 'greaterThanInclusive' | 'lessThan' | 'lessThanInclusive' | 'isEmpty' | 'isNotEmpty', required — Comparison applied to the resolved context value. `isEmpty` / `isNotEmpty` take no `value`; all other operators require one.
          - `value` union — Static comparison value for binary operators.
            - number
            - string
            - boolean
        - `allow_failure` boolean — When true, the condition is advisory: it is always evaluated and reported when it fails, but it never takes part in the validity verdict. The input is valid when every blocking (non-advisory) condition passes. A rule whose conditions are all advisory is always valid (warnings only).
  - `contexts` ContextRequirement[] — Declares the dynamic context a v2 rule needs at evaluation time. `context` condition values reference these sources by using the schema slug as the first segment of their `path`. Only applicable to v2 rules.
    - `schema` string, required — Entity schema slug.
  - `_schema_version` string, required — Schema version of the validation rule.
  - `_id` string, required — Unique identifier for the validation rule.
  - `_organization_id` string, required — Organization ID that owns this rule.
  - `created_at` string, required — ISO timestamp when the rule was created.
  - `updated_at` string, required — ISO timestamp when the rule was last updated.
  - `created_by` string, required — User ID of the creator.
  - `updated_by` string, required — User ID of the last updater.

## Other responses

- `400` — Bad Request - Invalid request body
- `401` — Unauthorized - Authentication required
- `403` — Forbidden - Insufficient permissions
- `404` — Validation rule not found
- `500` — Internal Server Error

---

[API](https://skmtc.dev/epilot/apis/validation-rules-api.md) · [All operations](https://skmtc.dev/epilot/apis/validation-rules-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/epilot/validation-rules-api/revisions/017fc8c03fb0/schema)
