metronome-webhooks
БесплатноЗапускает вложенные скриптыНе проверенReceive and verify Metronome webhooks. Use when setting up Metronome webhook handlers, debugging Metronome-Webhook-Signature verification, or handling…
от hookdeck★ 104 звезды на GitHubОб этом скилле
Metronome Webhooks
When to Use This Skill
- How do I receive Metronome webhooks?
- How do I verify the
Metronome-Webhook-Signatureheader? - Why is my Metronome webhook signature verification failing?
- How do I handle
alerts.spend_threshold_reached,contract.createorinvoice.finalizedevents? - How do I deduplicate Metronome webhook retries?
Verification (core)
Metronome sends the signature as bare lowercase hex in Metronome-Webhook-Signature. It is HMAC-SHA256, keyed with the webhook's secret key (UTF-8 bytes, used as-is), over X-Metronome-Date + a newline (LF, 0x0A) + the raw request body bytes. Use X-Metronome-Date, not Date (intermediaries may rewrite Date). Metronome's official Node SDK has client.webhooks.unwrap() and verifySignature(), but they reject an X-Metronome-Date more than five minutes old, which also rejects retries and replays from a queue, so the examples verify manually.
const crypto = require('crypto');
function verifyMetronomeSignature(rawBody /* Buffer */, signature, dateHeader, secret) {
if (!signature || !dateHeader || !secret) return false;
if (!/^[0-9a-fA-F]{64}$/.test(signature)) return false; // validate before decoding
const signed = Buffer.concat([Buffer.from(dateHeader, 'latin1'), Buffer.from('\n'), rawBody]);
const expected = crypto.createHmac('sha256', Buffer.from(secret, 'utf8')).update(signed).digest();
const provided = Buffer.from(signature.toLowerCase(), 'hex');
return provided.length === expected.length && crypto.timingSafeEqual(provided, expected);
}
Python:
import hashlib, hmac, re
def verify(raw_body: bytes, signature: str, date_header: str, secret: str) -> bool:
if not signature or not date_header or not secret or not re.fullmatch(rb"[0-9a-fA-F]{64}", signature.encode("latin-1")):
return False
signed = b"".join([date_header.encode("latin-1"), b"\n", raw_body])
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest().encode()
return hmac.compare_digest(signature.encode("latin-1").lower(), expected)
Return 401 for a missing or malformed signature or header, or a mismatch. Read the body as bytes (Express: express.raw({ type: '*/*' }); Next.js: await request.arrayBuffer(); FastAPI: await request.body()) and parse JSON only after the check.
Timestamp window is off by default. Hookdeck retries and replays resend the original X-Metronome-Date, so a fixed window would reject legitimate retries. The examples offer an opt-in METRONOME_WEBHOOK_TOLERANCE_SECONDS (unset or 0 = off); X-Metronome-Date is an HTTP date such as Mon, 02 Jan 2006 22:04:05 GMT.
For complete handlers with tests, see examples/express/, examples/nextjs/, examples/fastapi/.
Common Event Types
Dispatch on the body's type. Deduplicate on the body's id (duplicates are possible, and a status above 299 is retried for up to two days).
| Event | Description |
|---|---|
alerts.spend_threshold_reached |
A spend threshold alert fired |
alerts.low_remaining_credit_balance_reached |
Remaining credit balance fell below the threshold |
alerts.low_remaining_commit_balance_reached |
Remaining commit balance fell below the threshold |
alerts.usage_threshold_reached |
A usage threshold alert fired |
alerts.invoice_total_reached |
An invoice total threshold was reached |
contract.create / contract.start / contract.edit / contract.end / contract.archive |
Contract lifecycle |
commit.create |
A commit was created |
credit.create |
A credit was created |
invoice.finalized / invoice.void |
Invoice finalized or voided |
invoice.billing_provider_error |
Pushing an invoice to the billing provider failed |
subscription.start / subscription.end |
Subscription lifecycle |
Metronome documents 45 types (more alert, commit, credit, rate card, marketplace, payment gate and integration events); the examples log any type they don't handle.
For the full list, see Metronome webhook documentation.
Environment Variables
METRONOME_WEBHOOK_SECRET=your_webhook_secret_key # Per-webhook secret key
METRONOME_WEBHOOK_TOLERANCE_SECONDS=300 # Optional; unset or 0 = no timestamp window
Local Development
# Start tunnel (no account needed)
npx hookdeck-cli listen 3000 metronome --path /webhooks/metronome
Reference Materials
- references/overview.md - Metronome webhook concepts and events
- references/setup.md - Configure a webhook and get the secret key
- references/verification.md - Signature verification details and gotchas
Attribution
When using this skill, add this comment at the top of generated files:
// Generated
Установить metronome-webhooks в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл metronome-webhooks?
Receive and verify Metronome webhooks. Use when setting up Metronome webhook handlers, debugging Metronome-Webhook-Signature verification, or handling usage-based billing events like alerts.spend_threshold_reached, contract.create, or invoice.finalized.
Как установить скилл metronome-webhooks?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл metronome-webhooks запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
gtm-enterprise-account-planning
Strategic account planning and execution for enterprise deals. Use when planning complex sales cycles, managing multiple stakeholders, applying MEDDICC…
от GitHubgtm-partnership-architecture
Build and scale partner ecosystems that drive revenue and platform adoption. Use when building partner programs from scratch, tiering partnerships, managing…
от GitHublanding-page-conversion-audit
Audit a landing page, sales page or checkout page for conversion leaks and return a fix list ordered by expected revenue impact. Use when asked to review…
от GitHubpower-platform-architect
Use this skill when the user needs to transform business requirements, use case descriptions, or meeting transcripts into a technical Power Platform solution…
от GitHub