Webhooks and notifications
Get a webhook or an email when posts finish or an account needs attention.
A notification subscription sends events to a webhook URL or to email. Create as many as you need.
Events
| Event | When |
|---|---|
post.scheduled | A post was queued for later. |
post.published | Every platform in a post published. |
post.partial | Some platforms published, some failed. |
post.failed | Every platform failed. |
account.reauthorization_required | A connected account's access stopped working. Send the user through a reconnect. |
account.disconnected | A connected account was removed. |
Each post sends one final event with every platform's result in it, not one event per platform.
Create a subscription
curl -X POST https://api.postkey.dev/v1/notifications \
-H "x-access-key: $POSTKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channel": "webhook",
"eventTypes": ["post.published", "post.partial", "post.failed", "account.reauthorization_required"],
"webhook": { "url": "https://yourapp.com/postkey/webhook" }
}'{
"id": "ntf_51b2",
"channel": "webhook",
"enabled": true,
"eventTypes": ["post.published", "post.partial", "post.failed", "account.reauthorization_required"],
"webhook": { "url": "https://yourapp.com/postkey/webhook", "secret": "whsec_…" }
}The secret is shown once. Store it. You need it to check signatures.
| Field | Meaning |
|---|---|
channel | webhook (HTTPS URL) or email (1 to 10 recipients in email.recipients). |
eventTypes | The events to send. At least one. |
profileId | Optional. Only events for this profile. |
onlyScheduledPosts | Optional. Only events for posts that were scheduled. |
enabled | Optional. false pauses it. |
Send a test event first with POST /v1/notifications/test. List, update and delete subscriptions under /v1/notifications.
Payload
{
"version": "1",
"id": "evt_7c1d",
"type": "post.partial",
"createdAt": "2026-12-01T14:00:09Z",
"projectId": "prj_1",
"profileId": "prof_acme",
"data": {
"post": { "id": "post_8f21c", "status": "partial" },
"platforms": [
{ "platform": "instagram", "accountId": "int_ig_123", "success": false, "error": "This is a personal account. Instagram only publishes to Business or Creator accounts." },
{ "platform": "linkedin", "accountId": "int_li_456", "success": true, "platformPostUrl": "https://www.linkedin.com/feed/update/…" },
{ "platform": "twitter", "accountId": "int_x_789", "success": true, "platformPostUrl": "https://x.com/acme/status/…" }
]
}
}Account events carry data.account instead of data.post:
{
"version": "1",
"id": "evt_9a44",
"type": "account.reauthorization_required",
"createdAt": "2026-12-03T08:12:00Z",
"projectId": "prj_1",
"profileId": "prof_acme",
"data": { "account": { "id": "int_li_456", "platform": "linkedin", "username": "acme-co" } }
}Headers
| Header | Value |
|---|---|
X-Postkey-Event-Id | The event id. Use it to drop duplicates. |
X-Postkey-Event-Type | The event type. |
X-Postkey-Timestamp | Unix time in seconds when it was sent. |
X-Postkey-Signature | sha256= followed by the HMAC-SHA256 hex digest. |
Check the signature
The signature is an HMAC-SHA256 of <timestamp>.<raw body>, keyed with your subscription secret. Compute it over the raw request body, before any JSON parsing.
import crypto from "node:crypto";
import express from "express";
const app = express();
app.post("/postkey/webhook", express.raw({ type: "application/json" }), (req, res) => {
const timestamp = req.header("X-Postkey-Timestamp");
const signature = req.header("X-Postkey-Signature") ?? "";
const expected =
"sha256=" +
crypto.createHmac("sha256", process.env.POSTKEY_WEBHOOK_SECRET).update(`${timestamp}.${req.body}`).digest("hex");
const ok =
signature.length === expected.length && crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
if (!ok) return res.sendStatus(401);
const event = JSON.parse(req.body);
if (event.type === "post.partial") {
// Show the failed platforms to your user, then retry them.
}
res.sendStatus(200);
});Also reject events whose timestamp is more than a few minutes old.
Delivery and retries
- Each event is a
POSTwith a JSON body. Reply with any2xxwithin 10 seconds. - If your endpoint times out or returns an error, Postkey tries again, up to 3 attempts in total, with exponential backoff.
- The same event can arrive more than once. Use
idto skip ones you've already handled.