Pages in API reference

Webhooks

Ampost POSTs events to your https URLs as they happen, so you do not have to poll. Each webhook has its own URL, events and signing secret; you can have up to 10. These operations need the webhooks:write scope and a key that is not restricted to some platform sets. The dashboard manages webhooks under Setup → Webhooks.

The full secret is only in the response that creates the webhook and in an update with rotateSecret: true; store it then. Every other response has only secretPreview. Revoking the API key or disconnecting the app that created a webhook (or last changed its URL or rotated its secret), or the app losing webhooks:write, turns the webhook off with disabledReason: "key_revoked". Only the account owner can turn it back on, in the dashboard.

Events

  • post.scheduled: A post was scheduled, or its publish time changed. data.post.
  • post.unscheduled: A scheduled post went back to a draft (scheduledFor set to null). data.post.
  • post.discarded: A post that was not published was discarded (posts_delete), scheduled or not. data.post.
  • post.published: Every account of a post published. data.post.
  • post.partial: A post finished with some accounts published and some failed. data.post.
  • post.failed: Every account of a post failed. data.post.
  • post.platform.published: One account's post went live. data.post and data.platformPost.
  • post.platform.failed: One account's post failed. data.post and data.platformPost (with error).
  • post.platform.deleted: One account's post was deleted from its platform (posts_unpublish). data.post and data.platformPost.
  • post.platform.edited: One account's published text was edited on its platform (posts_edit_published). data.post and data.platformPost (with the new text).
  • post.approval_requested: Approval mode: a post was submitted for approval and waits for an approver. data.post (its approval holds proposedFor).
  • post.approved: Approval mode: an approver approved a post; it is scheduled at its proposed time or publishing now. data.post.
  • post.rejected: Approval mode: an approver rejected a post; it stays a draft. data.post, with the reason in approval.reason.
  • account.connected: An account was connected or reconnected. data.account.
  • account.disconnected: An account was disconnected: by you, by deleting its set, or by the platform. data.account.
  • account.needs_reconnect: An account's access was revoked, expired, or expires within 7 days and Ampost cannot renew it; reconnect it to keep publishing. data.account.
  • analytics.synced: Analytics for an account were refreshed. data holds the account, status and counts.
  • webhook.test: sent only by webhooks_test, whatever the webhook subscribes to.

data.post and data.platformPost have the shapes GET /api/posts/{postId} returns, and data.account the shape of an account. A post's metadata (your own JSON object of at most 4096 bytes, set when you create the post) is in every post event, so you can match events to your records.

account.disconnected
{
  "id": "4a9e2c7b-3d1f-4b8a-9c6e-1f5d3b7a9e28",
  "type": "account.disconnected",
  "createdAt": "2026-10-06T12:20:00.000Z",
  "data": {
    "account": {
      "id": "c41d8e2f-6a3b-4f9c-b1e5-7d2a9c4e6f80",
      "platform": "instagram",
      "platformSetId": "0b6e4d2a-9c3f-4e1b-8a7d-5f2c1e9b3d40",
      "platformAccountId": "17841400000000000",
      "username": "ampost.io",
      "avatarUrl": null,
      "status": "revoked",
      "scopes": [],
      "tokenExpiresAt": null,
      "tokenHealth": "inactive",
      "health": {
        "canPost": false,
        "needsReconnect": true,
        "issues": [
          {
            "code": "ACCOUNT_REVOKED",
            "severity": "error",
            "message": "The account is disconnected. Reconnect it with accounts_connect and its accountId."
          }
        ]
      },
      "platformMetadata": {
        "displayName": "Ampost",
        "accountType": "BUSINESS"
      },
      "createdAt": "2026-10-06T09:00:00.000Z",
      "updatedAt": "2026-10-06T12:20:00.000Z",
      "lastUsedAt": "2026-10-06T09:00:04.000Z"
    }
  }
}

Delivery and retries

  • Ampost-Signature: sha256=<hex>, the HMAC-SHA256 of <Ampost-Timestamp>.<raw body> keyed with the webhook's secret.
  • Ampost-Timestamp: Unix seconds when the attempt was signed.
  • Ampost-Event-Id: the event's id. Retries and redeliveries keep it, so store it and skip an id you have already handled.
  • Ampost-Event-Type and Ampost-Delivery-Id.

Answer with any 2xx within 10 seconds and do slow work afterwards. Anything else (another status, a redirect, a timeout) fails the attempt, and Ampost retries after 1 min, 5 min, 30 min, 2 h, 6 h, 12 h and 24 h (8 attempts in all). Events can arrive out of order. After 5 deliveries in a row fail all their retries, Ampost turns the webhook off (disabledReason: "failing") and shows it on the dashboard; fix the receiver and turn it back on. The delivery log keeps each delivery's attempts and last response for 30 days, and any delivery can be sent again.

Verify signatures

Compute the HMAC over the raw body exactly as received, before you parse the JSON, compare in constant time, and reject timestamps more than 300 seconds old.

verify.mjs
import crypto from "node:crypto";

// rawBody: the request body as received (a string or Buffer), before JSON.parse.
export function verifyAmpostWebhook(rawBody, headers, secret) {
  const timestamp = headers["ampost-timestamp"];
  const signature = headers["ampost-signature"];
  if (!timestamp || !signature || !/^\d+$/.test(timestamp)) return false;
  // Reject old requests so a captured one cannot be replayed.
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const expected =
    "sha256=" + crypto.createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex");
  return (
    expected.length === signature.length &&
    crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature))
  );
}
verify.py
import hashlib
import hmac
import time

# raw_body: the request body bytes as received, before json.loads.
def verify_ampost_webhook(raw_body: bytes, headers, secret: str) -> bool:
    timestamp = headers.get("Ampost-Timestamp", "")
    signature = headers.get("Ampost-Signature", "")
    if not timestamp.isdigit() or not signature:
        return False
    # Reject old requests so a captured one cannot be replayed.
    if abs(time.time() - int(timestamp)) > 300:
        return False
    message = timestamp.encode() + b"." + raw_body
    expected = "sha256=" + hmac.new(secret.encode(), message, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)
verify.rb
require "openssl"

# raw_body: the request body as received (request.raw_post in Rails), before JSON.parse.
# headers: request.headers in Rails, or a Hash with these header names.
def verify_ampost_webhook(raw_body, headers, secret)
  timestamp = headers["Ampost-Timestamp"].to_s
  signature = headers["Ampost-Signature"].to_s
  return false unless timestamp.match?(/\A\d+\z/) && !signature.empty?
  # Reject old requests so a captured one cannot be replayed.
  return false if (Time.now.to_i - timestamp.to_i).abs > 300

  expected = "sha256=#{OpenSSL::HMAC.hexdigest("SHA256", secret, "#{timestamp}.#{raw_body}")}"
  expected.bytesize == signature.bytesize && OpenSSL.fixed_length_secure_compare(expected, signature)
end

Endpoints