wallet.low_balance
Sent when the wallet balance is at or below your low-balance threshold, at most once every 24 hours.
Sent when the wallet balance is at or below your low-balance threshold, at most once every 24 hours.
wallet.low_balance is sent when the wallet balance is at or below the low-balance threshold you set in the console. Sautikit checks every 5 minutes and sends it at most once every 24 hours per wallet. It is also sent straight away when you change the threshold to a value above the current balance. The same alert goes out by email.
Subscribe by adding wallet.low_balance to the events of a webhook created with POST /v1/webhooks.
The body is flat JSON. The event name is in the X-Sautikit-Event-Kind header, not in the body.
{
"workspace_id": "01900000-0000-7000-8000-000000000002",
"balance_minor": 4800,
"currency": "KES",
"threshold": 5000,
"trigger": "cron_scan"
}| Field | Type | Description |
|---|---|---|
workspace_id | string (UUID) | The workspace whose wallet is low. |
balance_minor | integer | Current balance in minor units (KES cents). 4800 is KES 48.00. It can be negative. |
currency | string | Wallet currency, for example KES. |
threshold | integer | Your low-balance threshold, in minor units. |
trigger | string | cron_scan for the regular balance check, threshold_changed when you raised the threshold above the balance. |
| Header | Description |
|---|---|
X-Sautikit-Event-Kind | wallet.low_balance. Route on this. |
X-Sautikit-Event-Id | UUID of the event. Deduplicate on this. |
X-Sautikit-Delivery-Id | UUID of this delivery. |
X-Sautikit-Attempt | Attempt number, starting at 1. |
X-Sautikit-Timestamp | Unix time (seconds) when the delivery was signed. |
X-Sautikit-Signature | t=<timestamp>,v1=<hex HMAC-SHA256>. See Verify webhook signatures. |
X-Sautikit-Event-Id header.// verifyWebhook is the function from the "Verify webhook signatures" guide.
import { verifyWebhook } from "./verify-webhook.js";
export async function POST(req) {
const body = await req.text();
try {
verifyWebhook(body, req.headers.get("x-sautikit-signature") ?? "", process.env.WEBHOOK_SECRET);
} catch {
return new Response("Forbidden", { status: 403 });
}
if (req.headers.get("x-sautikit-event-kind") === "wallet.low_balance") {
const { balance_minor, threshold, currency } = JSON.parse(body);
console.warn(`Low balance: ${currency} ${balance_minor / 100} (threshold ${threshold / 100})`);
// top up, or alert your team
}
return new Response("OK", { status: 200 });
}wallet.top_up to clear the alert when money arrives.