Webhooks

Signed blockchain webhooks with retries and a delivery log

Every RpcNode event reaches your server as an HMAC-signed HTTP POST. If your server fails, we try again up to seven times, and every attempt is in the delivery log.

Webhooks carry address events, payments, transaction watches and blocks. They run on paid plans; on the Free plan you can save a webhook URL and test it on test networks (without block events). A new account can also start a free 7-day Starter trial from the cabinet.

Built for production

Signed

X-RpcNode-Signature carries a timestamp and an HMAC-SHA256 of the body. A retry is signed again with a fresh timestamp.

Retries

Anything but a 2xx answer, including a timeout, is retried after 10 s, 30 s, 2 min, 10 min, 1 h and 6 h: 7 attempts, then the delivery is dead.

Idempotency key

X-RpcNode-Delivery is the id of the delivery and stays the same on every retry. Store it and ignore repeats.

Delivery log

The cabinet and GET /webhooks/deliveries show every delivery and whether your server answered with a 2xx.

How to set it up

  1. 1

    Save your URL

    Set the URL and the networks per kind of event in the cabinet, or with PUT /webhooks. The secret is created on the first save.

  2. 2

    Verify and deduplicate

    Check the signature on the raw body, then look the delivery id up before you act.

  3. 3

    Answer with a 2xx

    Send the answer as soon as the body is verified. A redirect counts as a failure and is retried.

Verify a delivery

The signature is HMAC-SHA256 of "t.body" with the webhook secret, used as plain text. Compute it over the raw bytes before any JSON parsing, compare in constant time and reject a timestamp that is more than 5 minutes from your clock.

headersHTTP
X-RpcNode-Signature: t=1787347206,v1=9f2c1e0b7a2d4c58b1a6e9d07f42c5a18e6b3d90c4f7a2e15b8d3c6f9a0e7b41
X-RpcNode-Delivery:  3f9c1e0b7a2d4c58b1a6e9d07f42c5a18e6b3d90
X-RpcNode-Event:     payment
server.jsEXPRESS
import crypto from 'node:crypto'

app.post('/hooks/rpcnode', express.raw({ type: '*/*' }), async (req, res) => {
  // 1. verify: HMAC-SHA256 of "{t}.{raw body}" with your webhook secret
  const sig = Object.fromEntries(
    req.get('X-RpcNode-Signature').split(',').map((p) => p.split('=')),
  )
  const expected = crypto
    .createHmac('sha256', process.env.RPCNODE_WEBHOOK_SECRET)
    .update(`${sig.t}.`)
    .update(req.body)
    .digest('hex')
  const fresh = Math.abs(Date.now() / 1000 - Number(sig.t)) < 300
  const ok = fresh && sig.v1?.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(sig.v1), Buffer.from(expected))
  if (!ok) return res.sendStatus(401)

  // 2. deduplicate: the delivery id is the same on every retry
  const id = req.get('X-RpcNode-Delivery')
  if (await alreadyProcessed(id)) return res.sendStatus(200)

  // 3. handle, then answer 2xx
  const event = JSON.parse(req.body)
  await handle(req.get('X-RpcNode-Event'), event)
  await markProcessed(id)
  res.sendStatus(200)
})

Headers of a delivery

The names are code; what they mean is below.

NameWhat it is
X-RpcNode-Signaturet=<unix seconds>,v1=<hex>: when the attempt was signed and the HMAC-SHA256 of "t.body".
X-RpcNode-DeliveryThe delivery id, the same as delivery_id in the body and on every retry. Use it as an idempotency key.
X-RpcNode-EventThe kind of the delivery: payment, payout, address, tx, payment_order, block or test.
X-RpcNode-NetworkThe network of the block. Block deliveries only.
X-RpcNode-Block-HeightThe height of the block. Block deliveries only.

One body, two ways to receive it

The webhook and the WebSocket are separate transports with separate settings. The JSON body is the same, so one handler can serve both.

Webhook

A signed HTTP POST to your URL, with retries and a delivery log. Best for backends and queues.

WebSocket

A Pusher-compatible socket with the channels private-address-events, private-payments, private-tx-watch and private-blocks. Opening a socket is free; each event is billed like a webhook.

What is included and what to keep in mind

Included

  • A secret that stays the same until you rotate it
  • A free, signed test delivery with POST /webhooks/test
  • The delivery log, filtered by status
  • The same body over the WebSocket

Limits

  • After 7 failed attempts a delivery is dead: keep your own record of what you need
  • Block deliveries carry the raw block, which can be large; they are off by default and every delivery is charged
  • Events are billed in credits from the pool of your plan; test deliveries are not
  • The webhook secret is not the API key secret: they sign different things

Questions

What counts as a successful delivery?

Any 2xx answer. Anything else, including a redirect, an error or a timeout, is retried.

Can I get webhooks and the WebSocket at once?

Yes. They are separate transports with separate settings, and a delivery on one does not switch on the other.

How do I avoid handling an event twice?

Store X-RpcNode-Delivery. It is the same on every retry of a delivery.

Do webhooks cost credits?

Deliveries are billed like requests, from the same credit pool. Test deliveries are free, and so is opening a WebSocket.

Where can I see what was delivered?

In the delivery log in the cabinet, or with GET /webhooks/deliveries.

Send your first signed event

Start free, save a URL, fire a test delivery and check your handler before real events arrive.