POST /v1/notification-rules
Add a rule. Rules only see transactions and data that arrive after they are created.
Auth. Send the token in the X-Ledger-Token header.
Request body
application/json: object
| Field | Type | Required | Description |
|---|---|---|---|
name | string | required | |
event | string: one of income, large_spend, spend_digest, transaction, balance_below, sync_failed, uncategorized_over | required | |
threshold | integer | optional | Cents for income, large_spend, spend_digest and balance_below; a count for uncategorized_over. Not used by sync_failed or transaction. For spend_digest, the minimum total spent on a day before it reports. |
category | string | optional | Optional filter for income |
topic | string or null | optional | ntfy topic for this rule's alerts, on the same server as NTFY_URL. Null sends to the default topic. |
enabled | boolean | optional |
Responses
| Status | Meaning | Body |
|---|---|---|
201 | Added | NotificationRule |
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
{
"id": 0,
"name": "string",
"event": "income",
"threshold": 0,
"category": "string",
"topic": "string",
"enabled": true,
"created_at": "2026-10-11T00:00:00Z"
}
Code samples
Set KEY to your own token first.
curl
curl \
-X POST \
-H X-Ledger-Token:$KEY \
-H "Content-Type: application/json" \
-d '{"name": "string", "event": "income", "threshold": 0, "category": "string", "topic": "string", "enabled": true}' \
"https://api.sasek.org/ledger/v1/notification-rules"
JavaScript
const res = await fetch("https://api.sasek.org/ledger/v1/notification-rules", {
method: "POST",
headers: { "X-Ledger-Token": KEY, "Content-Type": "application/json" },
body: JSON.stringify({
"name": "string",
"event": "income",
"threshold": 0,
"category": "string",
"topic": "string",
"enabled": true
}),
});
const data = await res.json();
Python
import json
import os
import urllib.request
payload = { 'name': 'string',
'event': 'income',
'threshold': 0,
'category': 'string',
'topic': 'string',
'enabled': True}
request = urllib.request.Request(
"https://api.sasek.org/ledger/v1/notification-rules",
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))