Outbound webhooks
LPM.dev Registry sends the events of an organization or a personal account to your HTTPS endpoint. Personal webhooks need the Pro plan.
Each webhook has its own signing secret. The secret is a string of 64 hexadecimal characters. Use the string itself as the HMAC key. Do not decode it from hexadecimal.
The dashboard shows the secret only once, after you create the webhook. Store the secret in a secret manager.
Events
You select the events for each webhook in the dashboard. The X-LPM-Event header names the event of each request. Personal webhooks can receive package, Marketplace, and token events. Organization webhooks can receive all events.
| Group | Events |
|---|---|
| Packages | package.published, package.deleted, package.archived, package.unarchived |
| Members, organizations only | member.invited, member.added, member.removed, member.left, member.role_updated |
| Organization, organizations only | ownership.transfer.initiated, ownership.transfer.completed, org.deleted |
| Marketplace | package.purchased, subscription.created, subscription.renewed, subscription.cancelled |
| Tokens | token.created, token.revoked, token.rotated |
A test event from the dashboard has the name ping. LPM.dev Registry sends no token.revoked event when it revokes a token automatically, for example when the token's creator leaves the organization.
Request headers
| Header | Content |
|---|---|
X-LPM-Event | The event name |
X-LPM-Timestamp | The send time as Unix seconds |
X-LPM-Delivery-Id | The stable ID for one logical delivery |
X-LPM-Attempt-Id | The unique ID for this send attempt |
X-LPM-Retry | 0 for the first attempt, then the retry number |
Idempotency-Key | The stable delivery ID |
X-LPM-Signature-Version | 2 |
X-LPM-Signature-V2 | v2= plus the lowercase HMAC-SHA256 value |
X-LPM-Signature contains the old signature of the body only, for compatibility. New endpoints must use X-LPM-Signature-V2.
Signature message
Create the signature message from the exact header values and the raw request body. Do not parse the body and serialize it again.
lpm.webhook.v2
<timestamp>
<event>
<delivery-id>
<attempt-id>
<retry>
<raw-body>
Put a newline character after each field except the raw body. Calculate HMAC-SHA256 with the webhook secret.
Verification procedure
- Read the raw request body.
- If a version 2 header is missing, reject the request.
- If the timestamp differs from the server time by more than five minutes, reject the request.
- Create the signature message with the exact header values.
- Calculate the HMAC-SHA256 value.
- Compare the received value and the calculated value in constant time.
- Reserve the attempt ID for at least five minutes, with one atomic operation.
- If the attempt ID already exists, reject the request.
- Use the delivery ID as the idempotency key for the work that the event starts.
- Process the event only after all of these steps succeed.
Do not use the event name, the retry number, or the IDs before the version 2 signature is valid.
Node.js example
import { createHmac, timingSafeEqual } from "node:crypto"
export function verifyLpmWebhook({ headers, rawBody, secret, now = Date.now() }) {
const version = headers.get("x-lpm-signature-version")
const signature = headers.get("x-lpm-signature-v2")
const timestamp = headers.get("x-lpm-timestamp")
const event = headers.get("x-lpm-event")
const deliveryId = headers.get("x-lpm-delivery-id")
const attemptId = headers.get("x-lpm-attempt-id")
const retry = headers.get("x-lpm-retry")
if (
version !== "2" ||
!signature?.startsWith("v2=") ||
!timestamp ||
!event ||
!deliveryId ||
!attemptId ||
!/^\d+$/.test(retry || "")
) {
return { valid: false, reason: "missing_headers" }
}
const timestampSeconds = Number(timestamp)
if (
!Number.isSafeInteger(timestampSeconds) ||
Math.abs(Math.floor(now / 1000) - timestampSeconds) > 300
) {
return { valid: false, reason: "timestamp_outside_window" }
}
const message = [
"lpm.webhook.v2",
timestamp,
event,
deliveryId,
attemptId,
retry,
rawBody,
].join("\n")
const supplied = Buffer.from(signature.slice(3), "hex")
const expected = createHmac("sha256", secret).update(message).digest()
if (supplied.length !== expected.length) {
return { valid: false, reason: "invalid_signature" }
}
if (!timingSafeEqual(supplied, expected)) {
return { valid: false, reason: "invalid_signature" }
}
return { valid: true, event, deliveryId, attemptId, retry: Number(retry) }
}
The example verifies the signature and the timestamp. Your service must also reserve attempt IDs in shared, durable storage.
If more than one worker receives requests, an in-memory set does not prevent replays. Use a database or a shared cache with an atomic insert.
Retry and idempotency rules
A delivery fails if the endpoint does not return a 2xx status within 10 seconds. LPM.dev Registry retries a failed delivery up to three times. The retries start about 1, 5, and 30 minutes after the previous failed attempt.
LPM.dev Registry keeps the delivery ID the same for all retries. Each retry has a new attempt ID and a new timestamp.
Store the final result by delivery ID. If a later attempt has the same delivery ID, return the stored result. Do not do the work of the event again.
Keep attempt IDs for at least five minutes. Keep delivery IDs for as long as a duplicate action can cause harm.
See also
- Integrations lists the integrations and their entry points.
- Managing members explains organization roles and access changes.
- Request inspector explains how to inspect third-party webhooks during local development.