Receiving webhooks
A receiver does three things: verify the signature, answer 2xx fast, and deduplicate. The wire contract — envelope, headers, event catalog — is in Webhook events; this page is the receiving side.
Before you have a receiver
Section titled “Before you have a receiver”You don’t need an endpoint to start. Register a capture subscription instead: it has no URL and no signing secret, nothing is sent anywhere, and it goes Active immediately. Every matching event is recorded so you can read the exact envelope your endpoint would have received, which is the fastest way to settle on event types and filters before you write a line of code.
Captured deliveries are kept for 7 days, or the 1,000 most recent per capture subscription — whichever comes first. Switch to a real subscription once you know what you want to receive.
Endpoint requirements
Section titled “Endpoint requirements”- HTTPS, reachable from the internet.
- Respond 2xx fast — verify, persist, return; process asynchronously. A slow handler gets timed out and retried.
- Be ready as soon as you create the subscription. It delivers at once: Oclavex sends your URL nothing but signed events, so there is no handshake to answer. To check the URL, choose Send test event in the confirmation that appears after you create it, or use Test-fire later. A URL that keeps failing shows up under Failed deliveries.
- Hold the subscription’s signing secret server-side. It is a Standard Webhooks
secret,
whsec_followed by base64: the portal generates one when you create the subscription and shows it once, and a secret you supply through the API must have the same form (24 to 64 random bytes).
Local development
Section titled “Local development”https://localhost:5001 won’t be accepted — loopback, private and link-local
addresses, internal host names, plain http and a user name or password in the URL
(https://user:pw@host/...) are all refused with
400 subscription.invalid_url (error 4033), because
the platform must not be aimed at anything but a public endpoint. Put a tunnel in
front of your local receiver and register the tunnel’s public URL:
ngrok http 5001 # or: cloudflared tunnel --url http://localhost:5001Verify every delivery
Section titled “Verify every delivery”Deliveries are signed exactly as Standard Webhooks
specifies, so any Standard Webhooks library verifies them. Hand it the subscription’s
signing secret as the portal showed it (whsec_…), the headers, and the body as raw
text — read it before any JSON parsing, because re-serialized JSON won’t match.
// dotnet add package StandardWebhooks.StandardWebhooksusing System.Net;using Microsoft.AspNetCore.Http;using StandardWebhooks;
static void Verify(string secret, HttpRequest request, string body){ var headers = new WebHeaderCollection(); foreach (var (name, value) in request.Headers) headers.Add(name, value.ToString());
new Webhook(secret).Verify(body, headers); // throws WebhookVerificationException}// Node — npm install standardwebhooksconst { Webhook } = require("standardwebhooks");
new Webhook(secret).verify(body, headers); // throws if the delivery doesn't verify# Python — pip install standardwebhooksfrom standardwebhooks.webhooks import Webhook
Webhook(secret).verify(body, headers) # raises if the delivery doesn't verifyThe library checks everything a receiver has to: the signature, compared in constant
time; any one of several space-separated signatures, which is how a
secret rotation arrives; and a webhook-timestamp within five
minutes of now, which shuts down replays.
Without a library
Section titled “Without a library”The scheme is small enough to write yourself:
- The key is the part of the secret after
whsec_, base64-decoded — not the secret’s text. - The signed content is
{webhook-id}.{webhook-timestamp}.{raw body}. - The signature is
v1,followed by the base64 HMAC-SHA256 of that content.webhook-signaturecarries one or more, separated by spaces; accept the delivery if any one matches. webhook-timestampis the send time in Unix seconds. Reject a delivery whose timestamp is more than a few minutes from your clock.
using System;using System.Linq;using System.Security.Cryptography;using System.Text;
static class WebhookSignature{ public static string Sign(string secret, string id, string timestamp, string body) => "v1," + Convert.ToBase64String(HMACSHA256.HashData( Convert.FromBase64String(secret["whsec_".Length..]), Encoding.UTF8.GetBytes($"{id}.{timestamp}.{body}")));
public static bool Verify(string secret, string id, string timestamp, string body, string header) => long.TryParse(timestamp, out var sent) && Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - sent) <= 5 * 60 && header.Split(' ').Any(candidate => CryptographicOperations.FixedTimeEquals( Encoding.UTF8.GetBytes(candidate), Encoding.UTF8.GetBytes(Sign(secret, id, timestamp, body))));}// Nodeconst crypto = require("crypto");
const sign = (secret, id, timestamp, body) => "v1," + crypto .createHmac("sha256", Buffer.from(secret.slice("whsec_".length), "base64")) .update(`${id}.${timestamp}.${body}`) .digest("base64");
const verify = (secret, id, timestamp, body, header) => { const sent = Number(timestamp); if (!Number.isInteger(sent) || Math.abs(Date.now() / 1000 - sent) > 5 * 60) return false; const expected = sign(secret, id, timestamp, body); return header.split(" ").some(candidate => candidate.length === expected.length && crypto.timingSafeEqual(Buffer.from(candidate), Buffer.from(expected)));};using System.Net;using StandardWebhooks;using StandardWebhooks.Exceptions;
app.MapPost("/webhooks/oclavex", async (HttpContext ctx) =>{ var body = await new StreamReader(ctx.Request.Body).ReadToEndAsync(); var headers = new WebHeaderCollection(); foreach (var (name, value) in ctx.Request.Headers) headers.Add(name, value.ToString());
var webhook = new Webhook(secret); try { webhook.Verify(body, headers); } catch (WebhookVerificationException) { return Results.Unauthorized(); }
var envelope = JsonDocument.Parse(body).RootElement; await queue.EnqueueAsync(envelope, ctx.RequestAborted); // process async return Results.Ok();});Handle retries, replays and duplicates
Section titled “Handle retries, replays and duplicates”Delivery is at-least-once: a timeout after successful processing means the
same event arrives again. Record webhook-id (unique per event) and skip ids
you’ve already processed. A delivery that fails with a timeout, a 5xx, 408 or
429 is retried with exponential backoff for up to 3 days; any other status, such as
400 or 401, is not retried. What ultimately fails is kept for 30 days and can be retried
from the Failed deliveries tab in the portal. Oclavex also emails the person who created the
subscription, or the tenant administrator, when a delivery is dead-lettered, at most once per
subscription each day. See Delivery and
retries for the schedule.
A replay sends an event again under its original webhook-id, as a retry from the
Failed deliveries tab does. A receiver that skips ids it has already processed therefore skips the
replay, which is what you want after a partial outage. Only a replay carries data._replay
(replayedAt and requestedBy). To process a replayed event a second time on purpose,
check for data._replay and process the event even though its webhook-id is already
recorded. The envelope id is the original event id. Oclavex signs each replay with a new
webhook-timestamp, so the timestamp check described in
Verifying a delivery accepts it.
Events about one entity arrive in the order they happened, because Oclavex waits for an earlier event to be delivered or dead-lettered before it sends the next one about the same entity. Don’t rely on that across entities, and not after a retry from the Failed deliveries tab or a replay, which deliver an old event after newer ones. Treat each event as a signal to fetch current state when order matters. Order of events has the details.
Rotate the secret
Section titled “Rotate the secret”Rotate from the portal (Settings → Webhooks), or — for a subscription an
integration credential created — via
POST /api/v1/webhooks/integrator/subscriptions/{subscriptionId}/rotate-secret. During the overlap
window Oclavex signs with both secrets (space-separated in
webhook-signature), so a receiver that checks all candidates — as the
Standard Webhooks libraries and the snippets above do — rolls keys with zero
dropped events.
Call back with the delivery token
Section titled “Call back with the delivery token”If the subscription requests callback scopes, each delivery carries a
short-lived JWT in webhook-callback-token. Use it as a bearer token to call
back into the API with exactly those scopes. For example: on
MeteredUsage.OverageStatusChanged, read the balance — no stored credential, no
OAuth round-trip.
The scopes on offer cover licenses, sessions, usage, quotas, credit balances,
metrics and ratings, reading the catalog, and reading your customers and users.
For example: on Organization.BillingDetailsChanged, read the organization back
to get the new billing details. Changing the catalog, account administration,
sign-up, privacy and connector settings are not among them, and neither are
delete verbs or wildcards — see Calling back.
Callback tokens are off by default, and reading is the default when you turn one
on. The scope list in the create and edit dialogs shows read scopes first, under
Read your data, then write scopes under Change your data (you confirm on
save). A write scope is any scope that does not end in .read: .create,
.update or .write. Read scopes save without a question.
Saving a write scope the receiver did not hold before, or moving a subscription
that holds one to a new URL, opens Let this receiver change your data? It reads:
“Anyone who can see the requests sent to your URL can use the token in a delivery
once, within 15 minutes” to do what the scope allows, such as changing or
cancelling entitlements. Choose Grant and save, or cancel to save nothing. Through
the API, send acknowledgeWriteCallbackScopes: true with the request; without it the
request is refused with 400 subscription.callback_write_scope_unconfirmed (error
4036). Each confirmed grant is written to the audit
trail with the URL and the scopes.
Test it
Section titled “Test it”Test-fire in the portal, or Send test event in the confirmation after you create a subscription, lets you pick the event type, preview the exact payload, and send a sample event through the full pipeline — signature, headers, retry behavior — so you can validate the receiver before real traffic hits it.
The payload matches the documented schema for the chosen event type and always
carries "_test": true inside data, covered by the signature like the rest of
the body. Gate on _test: never apply a test event to real state — the sample
payloads reference fixed placeholder ids, not your data.