Events
Register an HTTPS endpoint and Locals tells you when a customer, route or transfer changes, with a signed event you can verify.
Each event goes as a POST to every endpoint that takes its type. Your endpoint checks the signature, stores the event and answers 2xx; until it does, Locals retries.
Register an endpoint
Call POST/v1/webhook-endpoints with the URL and the event types it receives. Leave events out to receive every type.
curl -X POST https://api.locals.money/v1/webhook-endpoints \
-H "Authorization: Bearer $LOCALS_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"url": "https://app.example/hooks/locals",
"events": ["route.deposit.received", "transfer.completed", "transfer.failed"]
}'The response carries the endpoint's signing secret, whsec_…. It is shown once: store it with your other secrets.
- The URL is public HTTPS, up to 2048 characters, without credentials or a fragment. Private and reserved addresses are refused.
- Up to 10 active endpoints per account. Each one gets its own copy of every event it takes.
- GET/v1/webhook-endpoints lists them; DELETE/v1/webhook-endpoints/{id} disables one and keeps its deliveries readable.
Send a test event
POST/v1/webhook-endpoints/{id}/test sends a signed webhook.test event to that endpoint only, right away, and answers with what happened:
{ "eventId": "evt_9b0e", "ok": true, "statusCode": 200, "durationMs": 184, "error": null }Use it to check your URL and your signature code before real events flow. The test event has data: { "endpointId": "we_…" }; it is not stored, not retried and not listed in GET/v1/events.
The event object
Every event has the same envelope:
| Field | Type | Description |
|---|---|---|
id | string | Unique event id, evt_…. The same in every retry and redelivery: use it to drop duplicates. |
type | string | What happened, from the list below. |
createdAt | string | ISO 8601 time of the change. |
data | object | The full object: a customer, a route or a transfer, in the same shape as its GET endpoint. |
{
"id": "evt_6f1a",
"type": "transfer.completed",
"createdAt": "2026-10-21T09:44:52.318Z",
"data": {
"id": "trf_91kd",
"kind": "route",
"customerId": "cus_8Hq2Lm",
"routeId": "route_3f9a",
"status": "complete",
"source": { "amount": "12500.00", "currency": "AUD", "rail": "local_transfer", "reference": "HC-2210", "senderName": "HARBOUR AND CO" },
"destination": { "amount": "8137.50", "currency": "USDC", "rail": "polygon", "address": "0x7a3f0000000000000000000000000000000091c2", "txHash": "0x5e0c…a7d4" },
"refundReason": null,
"actionRequired": null,
"statusHistory": [
{ "status": "processing", "at": "2026-10-21T09:41:07Z" },
{ "status": "complete", "at": "2026-10-21T09:44:52Z" }
],
"createdAt": "2026-10-21T09:41:07.903Z",
"updatedAt": "2026-10-21T09:44:52.318Z"
}
}data is the object as it was when the event was sent, a moment after the change. Two events about the same object sent together, for example route.deposit.received and transfer.completed of a deposit that settled at once, can carry the same data. If you need the state right now, read it again with its GET endpoint.
Event types
| Type | Sent when | data |
|---|---|---|
customer.updated | A change of the customer's status, its verification, a capability or a block. Not sent when the customer is created, nor for a change of email. Use data.version to drop an older one: see Version. | Customer |
customer.verification.updated | Being retired: use customer.updated, sent alongside it. Locals sees a change in a customer's status, verification or capabilities: approved, rejected, or action needed. Not sent when the customer is created. | Customer |
customer.blocked | Being retired: use customer.updated, sent alongside it. Locals or you block a customer. See Blocked customers. | Customer |
customer.unblocked | Being retired: use customer.updated, sent alongside it. The block is lifted. | Customer |
route.activated | A route becomes active: opened, created already active, or back from inactive. Show its deposit instructions from now on. | Route |
route.closed | A route is closed and takes no more deposits. | Route |
route.deposit.received | A bank transfer arrived on a route and a new kind: route transfer was created. | Transfer |
transfer.processing | A transfer moves to processing. A deposit is created already in processing, so it only sends route.deposit.received. | Transfer |
transfer.review | A transfer is held for review. | Transfer |
transfer.action_required | A held payout needs the end user to do something: see Wallet verification. | Transfer |
transfer.completed | A transfer's status becomes complete. | Transfer |
transfer.failed | A transfer's status becomes failed. | Transfer |
transfer.refunded | A transfer's status becomes refunded. | Transfer |
The transfer.* types cover both deposits (kind: route) and payouts (kind: quoted). Read data.kind to tell them apart. There is no event for pending or refunding transfers, nor for inactive routes, and cutting a route does not send a route event: read blocked on the route. A cut because a deposit went over a limit sends no event at all, not even customer.updated: see Cut routes. See Statuses and lifecycle for what each status means.
The request
Locals sends a POST to your URL with the event as the JSON body and these headers:
| Header | Value |
|---|---|
Content-Type | application/json |
User-Agent | Locals-Webhooks/1 |
Locals-Signature | t=<unix seconds>,v1=<hex>, with one v1 per signing secret |
Verify the signature
Locals-Signature: t=1792575892,v1=5f8a0c1e9b…tis the Unix time, in seconds, when Locals signed this attempt.v1is the HMAC SHA-256 of the stringt+.+ the raw request body, keyed with the endpoint's whole secret (whsec_included), in hex.- While you rotate the secret there are two
v1values, one per secret:t=…,v1=<old>,v1=<new>. Accept the request when anyv1matches. Parsing the header into a map keeps only the lastv1and breaks during a rotation.
To verify a request:
- Read the raw body as bytes, before any JSON parsing. Re-serialized JSON does not match the signature.
- Split the header on
,: readtand everyv1. - Reject the request if
tis more than 5 minutes away from your clock. This stops replayed requests. - Compute the HMAC SHA-256 of
t.bodywith your secret and compare it to eachv1in constant time. - Answer
400if nov1matches, and do not process the event.
const crypto = require('crypto');
const express = require('express');
const TOLERANCE_SECONDS = 300;
// Accepts the request if any v1 matches: there are two while a secret rotates
function verifySignature(rawBody, header, secret) {
const parts = (header || '').split(',');
const t = Number(parts.find((p) => p.startsWith('t='))?.slice(2));
if (!t || Math.abs(Date.now() / 1000 - t) > TOLERANCE_SECONDS) return false;
const expected = crypto.createHmac('sha256', secret).update(`${t}.`).update(rawBody).digest();
return parts
.filter((p) => p.startsWith('v1='))
.map((p) => Buffer.from(p.slice(3), 'hex'))
.some((v1) => v1.length === expected.length && crypto.timingSafeEqual(v1, expected));
}
const app = express();
app.post('/hooks/locals', express.raw({ type: 'application/json' }), async (req, res) => {
if (!verifySignature(req.body, req.get('Locals-Signature'), process.env.LOCALS_WEBHOOK_SECRET)) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body);
await saveEvent(event); // store first, ignoring ids you already have
res.sendStatus(200);
});import hashlib
import hmac
import json
import os
import time
from flask import Flask, abort, request
TOLERANCE_SECONDS = 300
app = Flask(__name__)
# Accepts the request if any v1 matches: there are two while a secret rotates
def verify_signature(raw_body, header, secret):
parts = [p.split("=", 1) for p in (header or "").split(",") if "=" in p]
t = next((v for k, v in parts if k == "t"), "")
if not t.isdigit() or abs(time.time() - int(t)) > TOLERANCE_SECONDS:
return False
signed = t.encode() + b"." + raw_body
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return any(hmac.compare_digest(expected, v) for k, v in parts if k == "v1")
@app.post("/hooks/locals")
def locals_hook():
raw = request.get_data()
if not verify_signature(raw, request.headers.get("Locals-Signature"), os.environ["LOCALS_WEBHOOK_SECRET"]):
abort(400)
save_event(json.loads(raw)) # store first, ignoring ids you already have
return "", 200Rotate the secret
Rotate without missing an event:
- POST/v1/webhook-endpoints/{id}/secrets adds a second secret and returns it once. From then on every event carries two
v1, the old one first. - Deploy the new secret to your receiver, which accepts either
v1. Check it with POST/v1/webhook-endpoints/{id}/test. - DELETE/v1/webhook-endpoints/{id}/secrets/{secretId} retires the old secret. The endpoint lists its secrets by
idandprefix, never the secret itself.
An endpoint has at most two secrets, and its last one cannot be retired. A retry is signed with the secrets the endpoint has when it goes out.
Handle events safely
- Answer fast. Store the event and answer
2xxwithin 10 seconds, the whole response included; do the work afterwards, in a queue or a job. A slower answer, a redirect or any other status counts as a failure. - Drop duplicates by
id. The same event can arrive more than once: retries, redeliveries and rare repeats all keep theid. Keep the ids you processed and skip any you have seen. - Do not rely on order. Events can arrive out of order. Use
data.statusanddata.statusHistory, not the order of arrival, and read the object again when in doubt. A customer carriesdata.version: skip acustomer.updatedwith a lowerversionthan the one you hold. - Ignore unknown types. New event types can be added. Answer
2xxto types you do not handle.
Retries
A failed delivery is retried at once, then after 1 min, 5 min, 30 min, 2 h, 6 h, 12 h and 24 h: 8 attempts over about 45 hours, then the delivery is failed. An endpoint whose deliveries all fail for 3 days is disabled, and stops receiving new events; once it is fixed, your admins enable it again in the backoffice.
GET/v1/events/{id}/deliveries shows each delivery of an event: its status, the attempts, what your endpoint answered last and when the next attempt goes.
Redeliver an event
POST/v1/events/{id}/redeliver sends an event again, with the same id, so your duplicate check still works:
- Without a body, every delivery of the event goes again.
- With
{ "endpointId": "we_…" }, only the one to that endpoint. If the endpoint did not take the event when it happened, for example an endpoint you registered later, the delivery is created now.
curl -X POST https://api.locals.money/v1/events/evt_6f1a/redeliver \
-H "Authorization: Bearer $LOCALS_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "endpointId": "we_2c81" }'The answer says how many deliveries go again because of the call. Asking again for the same endpoint reopens its delivery, never a second one; a delivery still waiting for its next attempt is not counted.
Redelivery has a limit: while 50 or more deliveries of your account are waiting to go out now, of any event, it is 409 too_many_pending_deliveries and nothing changes. Retries scheduled for later do not count. Send it again once those have gone out.
Catch up after downtime
Events go to the endpoints active when they are sent; an endpoint created or enabled later does not get older events. To catch up, list them with GET/v1/events: every event of your account, delivered or not.
- Without
after, newest first. - With
after=<event id>, the events after that one, oldest first. Page forward with the lastidyou got,limitup to 100, untilhasMoreisfalse.
curl "https://api.locals.money/v1/events?after=evt_6f1a&limit=100" \
-H "Authorization: Bearer $LOCALS_KEY"Process them through the same handler, with the same duplicate check. GET/v1/events/{id} reads one event.
Polling as a safety net
Events are the way to follow changes; keep a slow poll as a safety net, and run GET/v1/routes/{id}/reconciliation on a schedule.
| To check | Read | For example |
|---|---|---|
| A customer's verification | GET/v1/customers/{id} for each customer with a capability you need still processing or action_required | hourly |
| Routes still opening | GET/v1/routes/{id} for each pending route | every few minutes |
| Deposits | GET/v1/transfers with kind=route | hourly |
| Payouts in flight | GET/v1/transfers with kind=quoted&status=pending,processing,review | hourly |
- Read the first page and stop early. Transfers come most recently updated first, and routes newest first.
- Compare, then act. Store the last
statusyou saw for each object and act only when it changes, in the same function your event handler calls. - Stop at final statuses. A transfer in
complete,failedorrefunded, or a route inclosed, does not need polling for status. Acompletetransfer can still move torefunding, so keep a slow check on recent ones.