POST /v1/rules/preview
What a rule would match, without creating it
Auth. Send the token in the X-Ledger-Token header.
Request body
application/json: object
| Field | Type | Required | Description |
|---|---|---|---|
pattern | string | required | |
category | string | optional | Optional. Used to count how many would change. |
Responses
| Status | Meaning | Body |
|---|---|---|
200 | The preview | object |
400 | Request rejected | Error |
429 | Too many requests from this client address. Wait the number of seconds in Retry-After, then try again. | Error |
Example response
{
"pattern": "string",
"matches": 0,
"would_change": 0,
"sample": [
{
"id": 0,
"posted": "2026-10-11",
"amount_cents": 0,
"merchant": "string",
"category": "string"
}
]
}
Code samples
Set KEY to your own token first.
curl
curl \
-X POST \
-H X-Ledger-Token:$KEY \
-H "Content-Type: application/json" \
-d '{"pattern": "string", "category": "string"}' \
"https://api.sasek.org/ledger/v1/rules/preview"
JavaScript
const res = await fetch("https://api.sasek.org/ledger/v1/rules/preview", {
method: "POST",
headers: { "X-Ledger-Token": KEY, "Content-Type": "application/json" },
body: JSON.stringify({
"pattern": "string",
"category": "string"
}),
});
const data = await res.json();
Python
import json
import os
import urllib.request
payload = {'pattern': 'string', 'category': 'string'}
request = urllib.request.Request(
"https://api.sasek.org/ledger/v1/rules/preview",
method="POST",
headers={
"X-Ledger-Token": os.environ["KEY"],
"Content-Type": "application/json",
},
data=json.dumps(payload).encode(),
)
with urllib.request.urlopen(request) as response:
print(json.load(response))