Skip to Content

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

EventWhen
post.scheduledA post was queued for later.
post.publishedEvery platform in a post published.
post.partialSome platforms published, some failed.
post.failedEvery platform failed.
account.reauthorization_requiredA connected account's access stopped working. Send the user through a reconnect.
account.disconnectedA 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" }
  }'
Response
{
  "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.

FieldMeaning
channelwebhook (HTTPS URL) or email (1 to 10 recipients in email.recipients).
eventTypesThe events to send. At least one.
profileIdOptional. Only events for this profile.
onlyScheduledPostsOptional. Only events for posts that were scheduled.
enabledOptional. false pauses it.

Send a test event first with POST /v1/notifications/test. List, update and delete subscriptions under /v1/notifications.

Payload

post.partial
{
  "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:

account.reauthorization_required
{
  "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

HeaderValue
X-Postkey-Event-IdThe event id. Use it to drop duplicates.
X-Postkey-Event-TypeThe event type.
X-Postkey-TimestampUnix time in seconds when it was sent.
X-Postkey-Signaturesha256= 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.

webhook.js (Express)
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 POST with a JSON body. Reply with any 2xx within 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 id to skip ones you've already handled.

On this page