Skip to main content

Build

Modern Treasury Webhooks

HookdeckOfficialCertified

Receive and verify Modern Treasury webhooks. Use when setting up Modern Treasury webhook handlers, debugging X-Signature verification (hex HMAC-SHA256 of the raw body), routing on the X-Topic header and event field, or handling payment operations events like payment_order.completed, payment_order.failed, expected_payment.reconciled and incoming_payment_detail.completed.

  • New
  • v1.0.1
  • Reviewed Oct 21
  • No reviews yet

Capabilities

  • Verification (core)

    X-Signature is the lowercase hex HMAC-SHA256 of the raw request body, keyed with your webhook key (Developers…

  • Request Headers and Body

    The body is { "event": "completed", "data": { ...the object..

  • Common Event Types

    Events are named per topic

  • Local Development

Getting started

Full instructions

Example command

Local Development

npx hookdeck-cli listen 3000 modern-treasury --path /webhooks/modern-treasury

Instructions: SKILL.mdv1.0.1

Modern Treasury Webhooks

When to Use This Skill

  • How do I receive Modern Treasury webhooks?
  • How do I verify a Modern Treasury webhook signature (X-Signature)?
  • Why is my Modern Treasury webhook signature verification failing?
  • How do I tell a payment_order event from an expected_payment event? (X-Topic header plus body event)
  • How do I handle payment_order.completed, payment_order.failed or payment_order.reconciled?
  • How do I avoid processing the same Modern Treasury webhook twice (X-Webhook-ID)?

Verification (core)

X-Signature is the lowercase hex HMAC-SHA256 of the raw request body, keyed with your webhook key (Developers > Webhooks) used as a plain string. There is no timestamp and no prefix.

javascript
const crypto = require('crypto');

function verifySignature(rawBody, signature, webhookKey) {
  if (!signature || !webhookKey) return false;
  const expected = crypto.createHmac('sha256', webhookKey).update(rawBody).digest('hex');
  const received = Buffer.from(signature.trim().toLowerCase());
  const expectedBuf = Buffer.from(expected);
  return received.length === expectedBuf.length &&
    crypto.timingSafeEqual(received, expectedBuf);
}

// Node lowercases header names: read req.headers['x-signature'], not 'X-Signature'

Verify against the raw body bytes, before any JSON parsing. In Express use express.raw({ type: '*/*' }).

For complete handlers with tests, see examples/express/, examples/nextjs/, examples/fastapi/.

The official SDKs (modern-treasury on npm and PyPI) expose webhooks.validateSignature / validate_signature, but they compare with a plain ===/== and need a configured API client, so the examples verify manually with a timing-safe compare.

Request Headers and Body

Header Meaning
X-Signature Hex HMAC-SHA256 of the body
X-Topic Object category, e.g. payment_order, expected_payment
X-Webhook-ID Unique per webhook, stable across retries (use for idempotency)
X-Event-ID ID of the Event object
X-Delivery-ID Changes on every delivery attempt
X-Live-Mode true for live traffic, false for test

The body is { "event": "completed", "data": { ...the object... } }. The event is the bare event name; combine it with X-Topic (payment_order.completed) to route.

Common Event Types

Events are named per topic. Verified against the Modern Treasury docs:

Topic Events
payment_order created, updated, approved, denied, cancelled, begin_processing, finish_processing, acknowledged, confirmed, tentatively_reconciled, completed, reconciled, returned, failed, redrafted, reversed, held, resolved
expected_payment created, reconciled, partially_reconciled, tentatively_reconciled, unreconciled, overdue, archived
incoming_payment_detail created, tentatively_reconciled, completed, reconciled, returned, failed, return_failed, unreconciled
transaction created, reconciled, updated
return created, begin_processing, finish_processing, reconciled, completed, returned, failed, unreconciled
reversal created, begin_processing, finish_processing, completed, failed, returned, unreconciled

Other topics: balance_report, case, connection_legal_entity, decision, external_account, internal_account, ledger_account_settlement, ledger_transaction, legal_entity, user_onboarding. See references/overview.md for the full list.

Environment Variables

bash
MODERN_TREASURY_WEBHOOK_KEY=your_webhook_key_here

Local Development

bash
npx hookdeck-cli listen 3000 modern-treasury --path /webhooks/modern-treasury

No account required: the CLI creates a guest account on first run and provides a local tunnel plus a web UI for inspecting requests. Use the printed URL as your endpoint URL in Modern Treasury (sandbox accepts localhost URLs directly; production requires HTTPS). Use port 8000 for the FastAPI example.

Gotchas

  • Raw body only. Re-serialized JSON changes the bytes and breaks the signature.
  • Lowercase header lookup in Node. The Modern Treasury docs sample reads req.headers['X-Signature'], which is always undefined.
  • Respond within 5 seconds with a 2xx. Otherwise it is retried with exponential backoff, up to 15 attempts; the endpoint is then paused. Acknowledge fast and process async.
  • Duplicates happen. Retries reuse X-Webhook-ID, and a redrafted payment order can emit the same event again for the same id.
  • completed is not reconciled. Treat a payment order as fully settled at reconciled.
  • Same URL for live and test? Branch on X-Live-Mode.
  • Ignore X-Internal-Signature. It is for Modern Treasury's own use.

Reference Materials

  • references/overview.md - Topics, events, headers and payload structure
  • references/setup.md - Add a webhook endpoint and find the webhook key
  • references/verification.md - Signature details, SDK notes, debugging

Install webhook-handler-patterns alongside this skill:

  • Handler sequence
  • Idempotency
  • Error handling
  • Retry logic
  • stripe-webhooks - Stripe payment webhooks (HMAC-SHA256 with timestamp)
  • adyen-webhooks - Adyen payment notifications
  • checkout-com-webhooks - Checkout.com payment events
  • airwallex-webhooks - Airwallex payments and payouts
  • lithic-webhooks - Lithic card and payment events
  • revolut-webhooks - Revolut Business events
  • mollie-webhooks - Mollie payment webhooks
  • bridge-api-webhooks - Bridge stablecoin and payment events
  • webhook-handler-patterns - Idempotency, error handling, retry logic
  • hookdeck-event-gateway - Production webhook infrastructure

Explore more skills

Browse all
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Signing

SignedSLSA L2
Signed by
skills-hub.ai distributor
Method
Distributor-signed by skills-hub.aiSigned with the skills-hub.ai Ed25519 distributor key over this exact slug, version and content. Check it with `npx @skills-hub-ai/cli verify`.
Key
skills-hub-ed25519-2026-11
Signed

Reviews (0)

More from Hookdeck

View source →
razorpay-webhooksReceive and verify Razorpay webhooks. Use when setting up Razorpay webhook handlers, debugging X-Razorpay-Signature verification, or handling payment events like payment.captured, payment.failed, order.paid, refund.processed, or…3 installsvercel-log-drains-webhooksReceive and verify Vercel Log Drains deliveries. Use when setting up a Vercel log drain HTTP endpoint, debugging x-vercel-signature verification, passing the drain's endpoint test, or processing batched log entries from sources like…1 installsstripe-webhooksReceive and verify Stripe webhooks. Use when setting up Stripe webhook handlers, debugging signature verification, or handling payment events like payment_intent.succeeded, customer.subscription.created, or invoice.paid.1 installsalchemy-webhooksReceive and verify Alchemy Notify webhooks. Use when setting up Alchemy webhook handlers, debugging X-Alchemy-Signature verification, or handling onchain events like ADDRESS_ACTIVITY, NFT_ACTIVITY, or GRAPHQL (Custom Webhook).1 installstiktok-webhooksReceive and verify TikTok for Developers webhooks (Login Kit, Content Posting, Data Portability). Use when setting up TikTok webhook handlers, debugging TikTok-Signature verification, or handling events like authorization.removed,…1 installsfedex-webhooksReceive and verify FedEx Advanced Integrated Visibility (AIV) shipment tracking webhooks. Use when setting up an AIV webhook or "Try this webhook" in the FedEx Developer Portal, verifying the fdx-signature header (base64 HMAC-SHA256 of the…1 installs

Frequently asked questions about modern-treasury-webhooks

What does the modern-treasury-webhooks skill do?

Receive and verify Modern Treasury webhooks. Use when setting up Modern Treasury webhook handlers, debugging X-Signature verification (hex HMAC-SHA256 of the raw body), routing on the X-Topic header and event field, or handling payment operations events like payment_order.completed, payment_order.failed, expected_payment.reconciled and incoming_payment_detail.completed. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the modern-treasury-webhooks skill?

Run `npx @skills-hub-ai/cli install hookdeck-modern-treasury-webhooks` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/hookdeck-modern-treasury-webhooks/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does modern-treasury-webhooks work with?

modern-treasury-webhooks runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the modern-treasury-webhooks skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use modern-treasury-webhooks after installing it?

In Claude Code, type `/hookdeck-modern-treasury-webhooks` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the modern-treasury-webhooks skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.

Badge for your README

Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.

Install on Skills Hub badge preview
Markdown
[![Install on Skills Hub](https://skills-hub.ai/api/badges/skill/hookdeck-modern-treasury-webhooks)](https://skills-hub.ai/skills/hookdeck-modern-treasury-webhooks)
HTML
<a href="https://skills-hub.ai/skills/hookdeck-modern-treasury-webhooks"><img src="https://skills-hub.ai/api/badges/skill/hookdeck-modern-treasury-webhooks" alt="Install on Skills Hub"></a>

More options in the badge docs.