---
title: "Create a match rule"
method: POST
path: "/v1/contexts/{contextId}/rules"
tags: ["Configuration Match Rules"]
---

# Create a match rule

`POST /v1/contexts/{contextId}/rules`

Use this endpoint to create a new match rule within a specific context. Match rules define how transactions are matched during reconciliation.

## Path parameters

- `contextId` string, required

## Headers

- `X-Request-Id` string
- `X-Idempotency-Key` string

## Request body

- CreateMatchRuleRequest
  - `config` object
  - `priority` integer, required
  - `type` 'EXACT' | 'TOLERANCE' | 'DATE_LAG', required — Type of matching rule algorithm

## Response `201`

Successfully created match rule.

The response includes the `X-Idempotency-Replayed` header.

If the value is false, the request was just processed. If the value is true, the response is a replay of a previously processed request.

See [Retries and idempotency](/en/reference/retries-idempotency) for more details.

- MatchRuleResponse — Matching rule within a reconciliation context
  - `config` object — Rule configuration
  - `contextId` string — Context ID this rule belongs to
  - `createdAt` string — Creation timestamp in RFC3339 format
  - `id` string — Unique identifier for the rule
  - `priority` integer — Execution priority (lower = higher priority)
  - `type` 'EXACT' | 'TOLERANCE' | 'DATE_LAG' — Type of matching rule
  - `updatedAt` string — Last update timestamp in RFC3339 format

## Other responses

- `400` — Invalid request payload
- `401` — The request lacks valid authentication credentials.
- `403` — You do not have permission to access this resource.
- `404` — Context not found
- `409` — Priority conflict or idempotency conflict
- `500` — An unexpected error occurred on the server.

---

[API](https://skmtc.net/lerian/apis/identity-plugin.md) · [All operations](https://skmtc.net/lerian/apis/identity-plugin/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/lerian/identity-plugin/versions/25daba385532/schema)
