Webhooks
Get a signed event when a profile owner blocks their profile, by webhook or from the event feed.
A profile owner can ask Openhandle to stop serving their profile. When staff
confirm the block, Openhandle records a profile.blocked event for every
workspace. Use the event to delete the data you stored for that profile.
You get events in one of two ways. Both give the same events:
- Webhook (push). Openhandle sends each event to your endpoint as a signed
POST. - Event feed (pull). You read
GET /v1/webhook-eventswith your API key.
Reads of a blocked profile already return 451 with PROFILE_BLOCKED. That
only helps when you request the profile again. The webhook tells you without a
new request.
What sends an event
Only account-level blocks send an event. A deleted post (404,
POST_NOT_FOUND) and a private account (403, PROFILE_PRIVATE) do not send
an event. You see them only when you fetch again.
Events
| Event | When |
|---|---|
profile.blocked | Staff confirmed a profile owner's block. |
Set up an endpoint
Open Settings ā Webhooks in the dashboard. Add your URL and choose the events the endpoint gets.
- Use an
httpsURL on the public internet. Localhost and private IP addresses are refused. Redirects are not followed. - A workspace can have up to 5 endpoints.
- The signing secret starts with
whsec_. It is shown once, so store it in your secret manager. - Rotate the secret when you need a new one. The old secret stops working at once.
On the same page, you can pause an endpoint, send a test event, read the delivery log, and resend a delivery.
The request
Each delivery is a POST with a JSON body and these headers:
| Header | Value |
|---|---|
Content-Type | application/json |
User-Agent | Openhandle-Webhooks/1.0 |
X-Openhandle-Event | The event type, for example profile.blocked |
X-Openhandle-Event-Id | The event ID |
X-Openhandle-Timestamp | The send time in Unix seconds |
X-Openhandle-Signature | sha256= and the hex HMAC-SHA256 of the timestamp, a dot, and the raw body, keyed with the secret |
Deliveries are at-least-once, so one event can arrive more than once. Use
X-Openhandle-Event-Id to drop duplicates.
The body
{
"id": "6f1cā¦",
"type": "profile.blocked",
"environment": "live",
"createdAt": "2026-11-18T10:00:00Z",
"data": {
"platform": "instagram",
"platformId": "1234567",
"handle": "someone",
"blockedAt": "2026-11-18T09:58:00Z"
}
}platformId or handle can be null. A block always knows at least one of
them. Delete all data you stored for that profile. Match on platformId
first, because a handle can change.
Test events
Send test event in the dashboard sends a real profile.blocked event with
environment set to test. It names the synthetic test profile
northstar_forge_test (platform ID 910000000001), so your normal handler runs
on it. Check environment and skip test events in production.
A Test API key reads these test events from the feed. A Live key reads only live events.
Verify the signature
Check every request before you act on it. Each SDK does the check with one
call. It needs the raw request body, the headers, and the endpoint's signing
secret, and no API key. It returns the typed event, or fails with a
verification error whose code says why:
| Code | Cause |
|---|---|
missing_signature | X-Openhandle-Signature is missing or empty. |
missing_timestamp | X-Openhandle-Timestamp is missing or empty. |
invalid_timestamp | The timestamp is not Unix seconds. |
timestamp_out_of_tolerance | The timestamp is more than 5 minutes from now. |
invalid_signature | The signature does not match the body and the secret. |
invalid_payload | The body is not a webhook event. |
Answer 400 when the check fails. Use the raw body bytes: do not parse the
JSON and serialize it again first, because the bytes can change.
import { verifyWebhook, WebhookVerificationError } from '@openhandle/sdk/webhooks';
export async function POST(request: Request) {
const rawBody = await request.text();
try {
const event = verifyWebhook(rawBody, request.headers, process.env.OPENHANDLE_WEBHOOK_SECRET!);
if (event.environment === 'live' && event.type === 'profile.blocked') {
// Delete what you stored for event.data.platform and event.data.platformId.
}
return new Response(null, { status: 204 });
} catch (error) {
if (error instanceof WebhookVerificationError) {
return new Response(error.code, { status: 400 });
}
throw error;
}
}The webhook helper uses node:crypto, so it has its own import path. The main
@openhandle/sdk entry does not need it.
Without an SDK
Compute sha256= and the lower-case hex HMAC-SHA256 of the timestamp header, a
dot, and the raw body, keyed with the secret. Compare it with
X-Openhandle-Signature in constant time. Reject a timestamp that is more than
5 minutes from the current time.
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verifyWebhook(secret: string, headers: Headers, rawBody: Buffer): boolean {
const timestamp = headers.get('x-openhandle-timestamp') ?? '';
const signature = headers.get('x-openhandle-signature') ?? '';
if (!/^\d+$/.test(timestamp) || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
const digest = createHmac('sha256', secret).update(`${timestamp}.`).update(rawBody).digest('hex');
const expected = Buffer.from(`sha256=${digest}`);
const received = Buffer.from(signature);
return expected.length === received.length && timingSafeEqual(expected, received);
}Respond and retries
Answer with any 2xx status within 10 seconds. Any other status, a timeout, or
a connection error is a failure.
After a failure, Openhandle tries again. The delay doubles from 30 seconds up to
6 hours between tries. A delivery gets 22 tries over about 3 days. Then the
delivery is marked exhausted. You can resend a delivery from the dashboard at
any time.
When you pause an endpoint, its retries stop. When you resume it, every delivery that is not delivered or exhausted starts a new round of tries. Resume a paused endpoint before you resend one of its deliveries.
Read the event feed
The feed returns your workspace's events, oldest first, with the same bodies a webhook sends. Use it instead of a webhook, or to catch up after downtime. You do not need an endpoint to read it. The feed is not billed.
curl "https://api.openhandle.dev/v1/webhook-events?since=2026-11-18T00:00:00Z&limit=50" \
-H "Authorization: Bearer $OPENHANDLE_API_KEY"| Parameter | Value |
|---|---|
since | Optional. Return events created at or after this RFC 3339 timestamp. |
type | Optional. Return only events of this type, for example profile.blocked. |
limit | Optional. 1 to 100. The default is 50. |
cursor | Optional. The meta.cursors.next value of the previous page. |
{
"data": [
{
"id": "6f1cā¦",
"type": "profile.blocked",
"environment": "live",
"createdAt": "2026-11-18T10:00:00Z",
"data": {
"platform": "instagram",
"platformId": "1234567",
"handle": "someone",
"blockedAt": "2026-11-18T09:58:00Z"
}
}
],
"meta": { "cursors": { "next": null } }
}meta.cursors.next is null on the last page.
Keep polling
To poll for new events, store the createdAt of the last event you handled.
On the next poll, pass it as since. Events created in the same second can
arrive on the next poll again, and an event can commit a moment after a newer
one. So set since a minute before the last createdAt, and drop events whose
id you already handled.
Errors
The feed uses the normal error envelope.
| Status | Code | Cause |
|---|---|---|
400 | INVALID_SINCE | since is not an RFC 3339 timestamp. |
400 | INVALID_PARAMETER | limit, cursor, or type is not valid. |