> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postploy.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Postploy's MCP server for posting is https://api.postploy.com/mcp and signs in with OAuth. The REST API base URL is https://api.postploy.com/public/v1 and takes an API key as a Bearer token. The API calls channels accounts.

# Webhooks

> Get a request the moment a post goes live, fails or needs approval.

Webhooks tell your app when something happens in Postploy, so you don't have to keep asking. When an event happens, Postploy sends a `POST` request to your endpoint with the details.

## Add an endpoint

Owners and admins can add up to 10 endpoints per team.

> [tab] In the app
>
> Open **Settings › Webhooks**, click **Add endpoint**, then enter your URL and pick the events to send. Copy the signing secret it shows you, because it's shown only once.

> [tab] With the API
>
> ```bash theme={null}
> curl https://api.postploy.com/public/v1/webhooks \
>   -H "Authorization: Bearer $POSTPLOY_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "url": "https://example.com/postploy/webhooks",
>     "events": ["post.published", "post.failed"]
>   }'
> ```
>
> The response holds the endpoint's `secret`, starting with `whsec_`. It's shown only this once, so store it now.

Your endpoint must be a public `https` URL.

## Events

| Event | When it's sent |
| - | - |
| [`post.published`](https://docs.postploy.com/webhooks/events/post-published) | A post went live. `data.post.link` points to it. |
| [`post.failed`](https://docs.postploy.com/webhooks/events/post-failed) | A post couldn't be published. `data.post.failureReason` says why. |
| [`post.scheduled`](https://docs.postploy.com/webhooks/events/post-scheduled) | A post was added to the calendar: created, approved or moved to a new time. |
| [`post.pending_approval`](https://docs.postploy.com/webhooks/events/post-pending-approval) | A post is waiting for someone to approve it. |
| [`account.needs_reconnect`](https://docs.postploy.com/webhooks/events/account-needs-reconnect) | A channel lost access and must be reconnected. |

Most apps start with `post.published` and `post.failed`.

## What a request looks like

```http theme={null}
POST /postploy/webhooks HTTP/1.1
Content-Type: application/json
User-Agent: Postploy-Webhooks/1.0
Postploy-Event: post.published
Postploy-Delivery: 2e3f4a5b-6c7d-4e8f-9a0b-1c2d3e4f5a6b
Postploy-Signature: t=1894698004,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
```

```json theme={null}
{
  "id": "2e3f4a5b-6c7d-4e8f-9a0b-1c2d3e4f5a6b",
  "type": "post.published",
  "createdAt": "2030-01-15T09:00:04.000Z",
  "teamId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
  "data": {
    "post": {
      "id": "3f6c2a1b-9d8e-4f7a-b6c5-d4e3f2a1b0c9",
      "status": "published",
      "platform": "linkedin",
      "text": "Our spring blend is here. Bright, citrusy and roasted this week.",
      "link": "https://www.linkedin.com/feed/update/urn:li:share:7000000000000000000"
    }
  }
}
```

`data.post` has the same fields as a post from the API, without `actions`. `data.account` has the same fields as a channel. Some fields are left out above to keep it short.

Before you trust a request, [check its signature](https://docs.postploy.com/webhooks/verify.md).

## Answer quickly

Answer with any `2xx` status within 10 seconds. If your work takes longer, answer first and do the work afterwards, for example in a background job.

## Retries

If your endpoint doesn't answer with a `2xx` in time, Postploy tries again, up to 8 times over about an hour, waiting longer between each try.

Postploy switches an endpoint off when:

* 10 events in a row fail, after all their retries, or
* your endpoint answers `410 Gone`.

A switched-off endpoint shows why in its `disabledReason`. Turn it back on in **Settings › Webhooks**, or with [Update an endpoint](https://docs.postploy.com/api-reference/webhooks/update-an-endpoint.md) and `{ "enabled": true }`.

## Repeats and order

The same event can arrive more than once, for example when your answer is lost on the way back. Every try of a delivery has the same `Postploy-Delivery` id, so keep the ids you've handled and skip repeats.

Events can also arrive out of order. Use `createdAt` to tell which came first, or [get the post](https://docs.postploy.com/api-reference/posts/get-a-post.md) to see where it is now.

## Test and debug

* **Send a test.** [Send a test event](https://docs.postploy.com/api-reference/webhooks/send-a-test-event.md) or the button in **Settings › Webhooks** sends a `ping` event. It's sent even while the endpoint is switched off.
* **See what was sent.** [List deliveries](https://docs.postploy.com/api-reference/webhooks/list-deliveries.md) shows the last 50 deliveries and how your endpoint answered. Deliveries are kept for 30 days.
* **Send one again.** [Retry a delivery](https://docs.postploy.com/api-reference/webhooks/retry-a-delivery.md) sends it again with the same body and id.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.