Outbound webhooks
Questi contenuti non sono ancora disponibili nella tua lingua.
The Social Media App notifies your systems over HTTPS when something happens in a workspace, so an integration
built on /v1 does not have to poll. Every delivery is signed, retried with a fixed backoff and deduplicable by its
event_id. Payloads carry ids, statuses, timestamps and provider names only; fetch the
details with your API key (created under Settings → API keys, see Getting started).
Subscriptions
Section titled “Subscriptions”A subscription belongs to one workspace (product_id): an https endpoint URL and the list of events it receives.
| Route | Scope | Notes |
|---|---|---|
GET /v1/webhook-subscriptions?product_id= |
webhooks:read |
every subscription of the workspace, newest first; never a secret |
POST /v1/webhook-subscriptions |
webhooks:write |
Idempotency-Key required; body { "product_id", "url", "events": [...] } → 201 with secret (shown once); see Idempotent creation |
GET /v1/webhook-subscriptions/{id} |
webhooks:read |
ETag: "<version>" |
PATCH /v1/webhook-subscriptions/{id} |
webhooks:write |
If-Match required (428 without, 412 webhook_version_mismatch when stale); url and/or events, null = unchanged |
DELETE /v1/webhook-subscriptions/{id} |
webhooks:write |
204; the delivery history goes with it |
POST /v1/webhook-subscriptions/{id}/pause · /resume |
webhooks:write |
see Pause |
POST /v1/webhook-subscriptions/{id}/rotate-secret |
webhooks:write |
the new secret, once; see Rotation |
POST /v1/webhook-subscriptions/{id}/test |
webhooks:write |
202 { "delivery_id", "event_id" }: queues a ping (active subscriptions only) |
GET /v1/webhook-subscriptions/{id}/deliveries?status=&page=&page_size= |
webhooks:read |
status = all (default), pending, leased, delivered, failed, dead; page_size 1..100 |
POST /v1/webhook-subscriptions/{id}/deliveries/{deliveryId}/redeliver |
webhooks:write |
failed or dead deliveries only (409 webhook_delivery_not_redeliverable) |
The same routes serve the web app (Settings → Webhooks). webhooks:read and webhooks:write belong to the owner and admin
roles and can be granted to an API key by them; there are no MCP tools for webhooks.
Limits and rules:
- At most 10 subscriptions per workspace by default, whatever their status (
409 webhook_limit_reached; delete a disabled one to free its slot). - URL: absolute
https, no user name or password, no#fragment, at most 2048 characters (webhook_url_invalid,webhook_url_length). Its host must resolve to public addresses only (400 webhook_url_blocked): private, loopback, link-local, CGNAT and cloud metadata addresses are refused. The check runs at creation, at every URL change and again before every send; the connection goes to the address that was checked, so a DNS answer that changes later cannot reach a private network. Redirects are never followed: a3xxanswer is a failed attempt. - Events: at least one, all from the catalog below (
webhook_events_required,webhook_events_invalid);pingcannot be subscribed to. - The signature proves the delivery came from us; it does not make the URL secret. Do not put credentials in the URL, and authorize what the event asks you to do with your own checks.
Idempotent creation
Section titled “Idempotent creation”POST /v1/webhook-subscriptions requires an Idempotency-Key header, like POST /v1/posts (400 idempotency_key_required
without it; at most 128 characters, 400 idempotency_key_length). The key is scoped to the organization of the workspace
(product_id) and to the calling principal (the user and, for an API key, the key itself). Retrying with the same key and the same body creates nothing new and
returns the same subscription (201, Idempotent-Replayed: true) with "secret": null: the secret is shown only on the
original response, and the idempotency record never stores it. If you lost the original response, rotate the secret
(POST /v1/webhook-subscriptions/{id}/rotate-secret). The same key with another body, or from another principal of the
organization, is 409 idempotency_conflict. A retry that arrives while the first request with the same key is still running
creates nothing and is refused at once with 409 idempotency_in_progress (retryable: true, Retry-After in seconds): retry
after that delay with the same key to get the stored answer.
Changed 2026-11: a retry that arrives while the first request with the same key is still running is now refused with
409 idempotency_in_progress (retryable, with Retry-After) instead of creating a second subscription. Branch on code,
not on the 409 status alone: idempotency_conflict is never retried unchanged. Two requests with the same key never run
at the same time, but a failure of the server or its database between the creation and the storing of its answer can still
let a retry run again: a client that must be certain lists the subscriptions before it retries.
Request
Section titled “Request”POST <your url> with Content-Type: application/json; charset=utf-8, User-Agent: TheSocialMediaApp-Webhooks/1 and:
| Header | Value |
|---|---|
X-Tsma-Event-Id |
the event’s id: the same for every subscription that receives that occurrence and for every redelivery. Deduplicate on it. |
X-Tsma-Event-Type |
the event type (post.scheduled, …, or ping) |
X-Tsma-Timestamp |
the send time of this attempt, unix seconds (a redelivery carries a new one) |
X-Tsma-Delivery-Attempt |
1 for the first attempt, then 2, 3, … |
X-Tsma-Signature |
v1=<hex>; during a secret rotation v1=<hex>,v1=<hex> (current secret first) |
Answer with any 2xx within 10 s (the default timeout). The outcome is decided by the status line as soon as the
headers arrive; the response body is ignored (we read at most 64 KiB of it and stop).
Envelope and event catalog
Section titled “Envelope and event catalog”{ "event_id": "4b0e…", "event_type": "publication.published", "occurred_at_utc": "2026-10-20T12:00:00Z", "api_version": "v1", "organization_id": "…", "workspace_id": "…", "data": { "post_id": "…", "target_id": "…", "status": "published", "external_post_id": "…", "external_url": "https://…" }}workspace_id is the product id of /v1. null members are kept, so every payload of a type has the same keys. The order of
the keys is unspecified: parse it, and sign or verify the raw bytes exactly as received.
| Event type | When | data |
|---|---|---|
post.scheduled |
a post is scheduled (or published now) | post_id, version, scheduled_at_utc, timezone_id |
post.rescheduled |
a scheduled post was moved to another time in place (its queued publishing moved with it) | post_id, version, scheduled_at_utc, timezone_id, previous_scheduled_at_utc, previous_timezone_id |
publication.accepted |
a provider accepted a target and processes it (it enters processing; raised once, not on every poll) |
post_id, target_id, status: "processing", external_post_id, external_url |
publication.published |
a target was published | post_id, target_id, status: "published", external_post_id, external_url |
publication.failed |
a target failed | post_id, target_id, status: "failed", error_code |
publication.needs_review |
a target needs a person | post_id, target_id, status: "needs_review", error_code |
connection.reauthorization_required |
a social account must be reconnected | connection_id, provider |
export.ready |
a workspace export finished | export_id, product_id, bytes, expires_at_utc (no key, no URL: download with GET /v1/exports/{id}/download, {id} being the export_id, and a workspace:export key) |
plan.changed |
the workspace owner’s plan or billing interval changed | plan_key, previous_plan_key, interval (month | year | null for free or a grant; an interval change alone is announced only when both sides are non-null, so a granted plan with the paid subscription’s plan key is silent both ways), max_organizations, max_products_per_organization (workspaces per organization), max_accounts_per_product (connected accounts per workspace), and max_accounts_per_organization (deprecated: the products ceiling times the accounts ceiling); each ceiling is always present, null = unlimited |
plan.blocked |
writes are refused until the owner acts | reason (past_due | over_ceiling), previous_reason (none | past_due | over_ceiling) |
plan.unblocked |
writes work again | previous_reason (past_due | over_ceiling) |
ping |
POST …/test (synthetic, never subscribable) |
{} |
Changed 2026-11: budget.threshold_reached, usage.settled and statement.closed are no longer sent and can no
longer be subscribed to (the product has no usage charges, budget caps or statements any more). A subscription that listed them
keeps its other events: they are hidden from its events and the subscription stays active; a PATCH that names one of them is
refused with webhook_events_invalid like any unknown event.
error_code is a bounded code: an API error code (connection_not_active, publication_processing_timeout, …) or a
publishing reason (timeout, reconcile_unknown, rejected_after_acceptance); provider messages become provider_error.
GET /v1/publications/{id} (the post id) shows the target’s last_error, which is bounded too but by a slightly wider rule: it may keep
a short token detail the network chose (letters, digits and _, at most 34 characters, such as invalid_request:InvalidRecord,
which error_code reduces to provider_error); any other detail is withheld (see the Posts guide, “Target errors and
imported media”). Payloads never contain post text, account handles, provider
receipts, media URLs, tokens, e-mail addresses or free-text reasons. external_url is the provider’s public link to the
post (on Bluesky it contains the account handle).
Plan events
Section titled “Plan events”plan.changed, plan.blocked and plan.unblocked describe the plan of the workspace owner. One occurrence fans out to
every workspace of the owner’s active, archived and pending-deletion organizations (one delivery per active subscription that
lists the type). The event_id is the same for every workspace of one occurrence. When one change emits both plan.changed
and plan.blocked, they are enqueued in that order with distinct event_ids, but delivery order between events is not
guaranteed (parallel sends, retries): re-read GET /v1/workspaces/{organizationId}/plan instead of relying on the order.
Payloads carry no user id, billing id or organization name.
intervalisnullfor free or a plan granted by The Social Media App. An interval change alone is announced only when both sides are non-null, so a granted plan with the same plan key as the owner’s paid subscription sends noplan.changedwhen it starts or when it ends.- While plan enforcement is off (
enforced: falseon the plan route), noplan.blockedis sent (nothing is refused). Turning enforcement on announces the existing blocks asplan.blockedat the next background pass (by default about every ten minutes); turning it off announcesplan.unblockedthe same way. - An organization that changes owner sends no event: its plan becomes the new owner’s, so re-read
GET /v1/workspaces/{organizationId}/plan. A block the transfer causes is announced at the next background pass. - There is no initial event. Starting a first checkout records the owner’s current plan (
free) without an event, so the paid subscription that follows announcesplan.changed(free→ the paid plan). A plan granted by The Social Media App to an owner who never started a checkout is recorded without an event, and an owner who never started a checkout and was never granted a plan gets no plan event at all.
Events are a prompt to re-read: they follow the recorded state, which can lag the live evaluation, and
GET /v1/workspaces/{organizationId}/plan is authoritative. Read it once after you create a subscription to learn the
current state instead of waiting for an initial event.
Verifying a delivery
Section titled “Verifying a delivery”The signature is HMAC-SHA256(secret, "{X-Tsma-Timestamp}.{raw body}") in lowercase hex. Compute it over the raw body as
received (before parsing JSON), compare in constant time with every v1= value of the header, and reject timestamps more than
5 minutes from your clock (replay window). Then deduplicate on X-Tsma-Event-Id: delivery is at least once, so the same
event can arrive twice (a lost answer, a redelivery).
Test vector: secret whsec_test, X-Tsma-Timestamp: 1700000000, body {"event_id":"00000000-0000-0000-0000-000000000001"} →
X-Tsma-Signature: v1=1154b8a0311b735d775894e48425aea98fa1d55c49be8e04097312323033bf67.
TypeScript (Node.js), the exact code our test suite runs against the vector:
import { createHmac, timingSafeEqual } from 'node:crypto';
/** * Verifies a webhook delivery from The Social Media App. `timestamp` is the X-Tsma-Timestamp header, `body` the raw request body * (exactly as received, before any JSON parsing) and `signatureHeader` the X-Tsma-Signature header (`v1=<hex>[,v1=<hex>]`). * Accepts the delivery when any v1 value matches and the timestamp is within the tolerance (5 minutes by default). */export function verifyWebhook(secret: string, timestamp: string, body: string, signatureHeader: string, nowSeconds: number, toleranceSeconds = 300): boolean { const sentAt = Number(timestamp); if (!Number.isInteger(sentAt) || Math.abs(nowSeconds - sentAt) > toleranceSeconds) return false;
const expected = Buffer.from(createHmac('sha256', secret).update(`${timestamp}.${body}`, 'utf8').digest('hex'), 'utf8'); return signatureHeader .split(',') .map((part) => part.trim()) .filter((part) => part.startsWith('v1=')) .some((part) => { const candidate = Buffer.from(part.slice(3), 'utf8'); return candidate.length === expected.length && timingSafeEqual(candidate, expected); });}Retries, dead letters and redelivery
Section titled “Retries, dead letters and redelivery”Every send counts as an attempt: a non-2xx answer (3xx included), a timeout (no response headers within the timeout, 10 s by default), a connection
failure (transport, which includes a connect timeout) or an address refused at send time (url_blocked). A delivery interrupted on our side (the sending process stopped before it finished) also counts. After a failed attempt the delivery
is failed and waits:
| After attempt | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| Next attempt in | 1 min | 5 min | 30 min | 2 h | 6 h | 12 h | 24 h | — (dead) |
After the 8th failure (the default number of attempts, about 2.5 days in all) the delivery is dead. The deliveries list shows each
delivery’s attempts, last_status_code and last_error (timeout, transport, url_blocked, gone, status:<code>;
never your response body). POST …/deliveries/{id}/redeliver puts a failed or dead delivery back in the queue with the
same event_id and payload, a fresh attempt budget and, at send time, a new timestamp and signature.
- 20 consecutive dead deliveries (by default) pause the subscription automatically
(
status: "paused",status_reason: "failing"). Fix the endpoint, resume, then redeliver what you need. 410 Gonedisables the subscription at once (status: "disabled",status_reason: "gone"); it cannot be resumed. Change its URL withPATCHto activate it again.- By default, delivered rows are kept for 14 days after their delivery and dead rows for 30 days after they died; a redelivery starts that age again.
Pause and automatic pause
Section titled “Pause and automatic pause”POST …/pause stops deliveries: events that happen while a subscription is paused or disabled are not recorded for it
and are never delivered later; deliveries already queued wait and flow again after POST …/resume. Resume also resets the
dead counter. A newly created (or resumed) subscription usually receives events at once, and by default within 15 seconds at most: a
server that recently saw the workspace without any active subscription may skip events for up to that long. Use the test
button (POST …/test) to check the wiring.
Secret rotation
Section titled “Secret rotation”POST …/rotate-secret returns a new secret once. For 24 hours by default the previous secret keeps
signing too: deliveries carry two v1= values (the new one first), so you can deploy the new secret without dropping a
delivery. Rotating again during an overlap drops the oldest secret (one previous secret at most). Secrets are generated by us
(whsec_ + 32 random bytes), stored only encrypted, and never shown again by any read.