---
title: "Add or replace a key rule"
method: POST
path: "/v1/contracts/key-rules"
tags: ["Contracts"]
---

# Add or replace a key rule

`POST /v1/contracts/key-rules`

## Request

- Base URL: `https://api.talonic.com`
- URL: `https://api.talonic.com/v1/contracts/key-rules`
- Auth: HTTP bearer

Documents later filed under `from_key` (at `site`, or all of them) go to `to_key`. A rule for the same `from_key` and site is replaced and re-activated. Documents already filed stay where they are until they are re-read or re-keyed.

## Request body

- object
  - `from_key` string, required: The key the document store files the documents under.
  - `site` string: Only documents at this site; all documents of `from_key` when omitted.
  - `to_key` string, required
  - `note` string

## Response `201`

The stored rule.

- ContractsKeyRule
  - `id` string, uuid
  - `customer_id` string, uuid
  - `from_key` string
  - `site` string: A normalized site key; empty means every document of `from_key`.
  - `to_key` string
  - `note` string, nullable
  - `created_by` string, nullable
  - `active` boolean
  - `created_at` string, date-time
  - `updated_at` string, date-time

## Other responses

- `400`: The request is invalid.
- `422`: The request is well-formed but violates the declared task contract.

## Changes

- **2026-10-28** `0a485a46163e`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/talonic/apis/talonic-api/changes/v1/contracts/key-rules/post.md)

---

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