usps-webhooks
БесплатноЗапускает вложенные скриптыНе проверенReceive and verify USPS webhooks (Subscriptions - Tracking API v3.2). Use when setting up USPS tracking webhook handlers, debugging X-HMAC signature…
от hookdeck★ 104 звезды на GitHubОб этом скилле
USPS Webhooks
USPS delivers webhooks through the Subscriptions - Tracking API (v3.2). You
create a subscription (POST /subscriptions) with a listenerURL, a 32-char
secret, adminNotification emails and filterProperties (a Mailer ID or a
tracking number, plus trackingEventTypes). USPS then POSTs a notification to
your listener URL when there is new scan activity.
When to Use This Skill
- How do I receive USPS tracking webhooks?
- How do I verify the USPS
X-HMACwebhook signature? - How do I create a USPS tracking subscription?
- How do I handle USPS tracking scans and
trackingEvents? - Why is my USPS webhook signature verification failing?
Verification (core)
USPS signs timestamp + payload — the notification envelope's timestamp
field concatenated with the raw, stringified payload field — with
HMAC-SHA256 keyed on your subscription secret, and sends the Base64
digest in the X-HMAC header (deprecated alias: hmac-header).
You must parse the envelope to read timestamp and payload, then compute
the HMAC over their concatenation. Do not re-serialize the inner payload —
sign the raw string exactly as received. Compare timing-safe.
The OAuth2 token (used to create subscriptions) is not sent on delivery. Per-message authenticity comes from the
X-HMACsignature and/or IP allowlisting. If you set nosecretand no IP allowlist, there is no per-message verification.
When USPS_WEBHOOK_SECRET is unset, a subscription created without a
secret sends no X-HMAC header at all — there is nothing to verify. Do not
pass the missing secret into createHmac / hmac.new; that throws and turns a
configuration problem into an opaque 500. The examples here branch explicitly:
they log a one-time warning that notifications are being processed with no
per-message verification (and that IP allowlisting should be used instead), then
process the delivery. Swap that branch for a rejection if your deployment cannot
rely on an allowlist — see
references/verification.md.
Node:
const crypto = require('crypto');
function verifyUspsSignature(timestamp, payload, hmacHeader, secret) {
if (!hmacHeader || !secret) return false; // nothing to verify against
const expected = crypto
.createHmac('sha256', secret)
.update(timestamp + payload) // payload = raw stringified JSON, unmodified
.digest('base64');
try {
return crypto.timingSafeEqual(Buffer.from(hmacHeader), Buffer.from(expected));
} catch {
return false; // length mismatch = invalid
}
}
Python:
import hmac, hashlib, base64
def verify_usps_signature(timestamp: str, payload: str, hmac_header: str, secret: str) -> bool:
if not hmac_header or not secret: # nothing to verify against
return False
expected = base64.b64encode(
hmac.new(secret.encode(), (timestamp + payload).encode(), hashlib.sha256).digest()
).decode()
return hmac.compare_digest(hmac_header, expected)
For complete handlers with route wiring, event dispatch, and tests, see:
Notification Envelope
USPS's Tracking Subscription Event example, with payload shortened here:
{
"subscriptionId": "123456789",
"subscriptionType": "TRACKING",
"timestamp": "2024-12-27T19:05:42.747Z",
"payload": "{\"trackingNumber\":\"12345678\",\"status\":\"Delivered, Front Door/Porch\",\"trackingEvents\":[{\"eventCode\":\"01\",\"eventType\":\"Delivered, Front Door/Porch\",\"GMTTimestamp\":\"2025-02-07T17:55:12Z\"}]}"
}
subscriptionId, subscriptionType, timestamp and payload are required;
links is optional. payload is a stringified JSON: JSON.parse() it
after verification. The HMAC is computed over timestamp + payload using the
raw payload string (not the parsed object).
What Arrives
USPS has no event-name enum. subscriptionType names the topic, and both
documented tracking examples carry TRACKING. Which updates arrive is set when
you create the subscription, in filterProperties.trackingEventTypes:
| Filter | Sends |
|---|---|
ALL_UPDATES (default) |
Every new tracking update, except package delays |
DELIVERY_ACTIVITY |
Deliveries, delays, and actions needed (e.g. Schedule Redelivery or Pickup) |
PACKAGE_DELAYED |
Package delays |
SCAN_EVENT_EXTRACT (MID subscriptions only) |
Every update in the Detailed Scan format, which adds mailer, address and electronic file fields |
The filter is not sent on the notification and can't be edited later, so if your
code needs to know which shape it got, record each subscription's filter against
its subscriptionId.
Inside a tracking payload:
statusis free text such asDelivered, Front Door/Porch, so don't switch on exact status strings.trackingEvents[]holds scans. `
Установить usps-webhooks в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл usps-webhooks?
Receive and verify USPS webhooks (Subscriptions - Tracking API v3.2). Use when setting up USPS tracking webhook handlers, debugging X-HMAC signature verification, creating tracking subscriptions, or handling package tracking events, retries and subscription suspension.
Как установить скилл usps-webhooks?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл usps-webhooks запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic