---
title: "Move a rule"
method: POST
path: "/v1/rules/{rule_id}/move"
tags: ["Rules"]
---

# Move a rule

`POST /v1/rules/{rule_id}/move`

## Request

- Base URL: `https://api.scrip.dev`
- URL: `https://api.scrip.dev/v1/rules/{rule_id}/move`
- Auth: HTTP bearer

Move one `ACTIVE` or `SUSPENDED` rule to the first or last position, or before or after another rule, in the same or another rule set.

## Path parameters

- `rule_id` string, uuid, required

## Headers

- `Idempotency-Key` string

## Request body

- MoveRuleRequest: Moves a rule to a position in a rule set, which may be a different set.
  - `expected_rule_configuration_version` integer, required: Current rule_configuration_version from the configuration read endpoint. A stale value rejects the request.
  - `position` SemanticPositionRequest, required: Where to place a resource: first, last, or before or after another resource.
    - `placement` 'before' | 'after', required: Placement within the destination collection.
    - `reference_id` string, uuid, required: Stable sibling ID. Required for before/after and omitted for first/last.
  - `rule_set_id` string, uuid, required: Destination rule-set ID. It may be the rule's current set.

## Response `200`

The moved rule, both rule sets in their new order, and the new rule_configuration_version

- MoveRuleResponse: The moved rule and the renumbered rules in the source and destination rule sets.
  - `destination_rules` PositionedRuleResponse[]: Complete renumbered sequence in the destination set.
    - `id` string, uuid: The id of the rule. It does not change when the rule moves.
    - `name` string: The name people see for the rule.
    - `order` integer: Position within the containing rule set.
    - `rule_set_id` string, uuid: Rule set containing the rule after the mutation.
    - `status` 'ACTIVE' | 'SUSPENDED': ACTIVE or SUSPENDED lifecycle status.
  - `rule` PositionedRuleResponse: A rule and its position in its rule set.
    - `id` string, uuid: The id of the rule. It does not change when the rule moves.
    - `name` string: The name people see for the rule.
    - `order` integer: Position within the containing rule set.
    - `rule_set_id` string, uuid: Rule set containing the rule after the mutation.
    - `status` 'ACTIVE' | 'SUSPENDED': ACTIVE or SUSPENDED lifecycle status.
  - `rule_configuration_version` integer: Resulting program rule-configuration version.
  - `source_rule_set_id` string, uuid: Rule set that contained the rule before the move.
  - `source_rules` PositionedRuleResponse[]: Complete renumbered sequence left in the source set.
    - `id` string, uuid: The id of the rule. It does not change when the rule moves.
    - `name` string: The name people see for the rule.
    - `order` integer: Position within the containing rule set.
    - `rule_set_id` string, uuid: Rule set containing the rule after the mutation.
    - `status` 'ACTIVE' | 'SUSPENDED': ACTIVE or SUSPENDED lifecycle status.

## Other responses

- `400`: The body is malformed, or expected_rule_configuration_version is missing (code: validation_error | invalid_json)
- `401`: The API key is missing or not valid. See [Authentication](https://docs.scrip.dev/authentication).
- `403`: The caller is not allowed to do this.
- `404`: The rule or the destination rule set was not found (code: rule_not_found)
- `409`: expected_rule_configuration_version is behind the live version (code: rule_configuration_version_conflict)
- `422`: position.reference_id is not in the destination rule set, or the rule or program is archived (code: invalid_position | archived_resource)
- `429`: Too many requests. Wait the number of seconds in the `Retry-After` header, then retry. See [Limits and durations](https://docs.scrip.dev/limits#rate-limits).
- `500`: Something failed on Scrip's side. Retry the request, and quote `request_id` if it keeps failing. [Errors](https://docs.scrip.dev/errors) lists every code, and the [API introduction](https://docs.scrip.dev/api-reference/introduction) describes the error format.

---

[API](https://skmtc.dev/scrip/apis/scrip-api.md) · [All operations](https://skmtc.dev/scrip/apis/scrip-api/llms.txt) · [OpenAPI document](https://skmtc.dev/scrip/apis/scrip-api/revisions/c52d35da8d97?raw)
