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 (scheduledForset 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.postanddata.platformPost.post.platform.failed: One account's post failed.data.postanddata.platformPost(witherror).post.platform.deleted: One account's post was deleted from its platform (posts_unpublish).data.postanddata.platformPost.post.platform.edited: One account's published text was edited on its platform (posts_edit_published).data.postanddata.platformPost(with the newtext).post.approval_requested: Approval mode: a post was submitted for approval and waits for an approver.data.post(itsapprovalholdsproposedFor).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 inapproval.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.dataholds the account, status and counts.webhook.test: sent only bywebhooks_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.
{
"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'ssecret.Ampost-Timestamp: Unix seconds when the attempt was signed.Ampost-Event-Id: the event'sid. Retries and redeliveries keep it, so store it and skip an id you have already handled.Ampost-Event-TypeandAmpost-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.
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))
);
}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)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)
endEndpoints
- GETList webhooks
/api/webhooks/endpoints - POSTCreate a webhook
/api/webhooks/endpoints - GETGet a webhook
/api/webhooks/endpoints/:webhookId - PATCHUpdate a webhook
/api/webhooks/endpoints/:webhookId - DELETEDelete a webhook
/api/webhooks/endpoints/:webhookId - POSTSend a test event
/api/webhooks/endpoints/:webhookId/test - GETList webhook deliveries
/api/webhooks/endpoints/:webhookId/deliveries - POSTRedeliver an event
/api/webhooks/endpoints/:webhookId/deliveries/:deliveryId/redeliver