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

# Webhooks

> Get a request at your own URL when posts are scheduled, published or fail, and when accounts change.

> [!NOTE]
>
> Available on the Team, Advanced and Business plans. Not included in Starter or the lifetime plans.

A webhook sends a request to your URL each time a chosen event happens in a workspace.

## Create a webhook

1. In the sidebar, under **Configuration**, click **Webhooks**.
2. Click **Create webhook**.
3. Fill in the details:
   * **Name** and **Callback URL**.
   * **Method**: POST (default), GET, PUT or DELETE.
   * **Content-Type**: use `application/json`.
   * **Max attempts**: 1, 2 or 3 tries in total.
   * **Secret (Optional)**: used to sign each request. See [Verify the signature](#verify-the-signature).
4. Under **Events**, tick the events you want.
5. Click **Create** and confirm your password if asked.

To check it works, open the webhook's menu and click **Test webhook**. This sends a `test` event.

## Events

| Event | When it's sent |
| - | - |
| `post.scheduled` | A post is scheduled. |
| `post.published` | A post is published to an account. Sent once per account. |
| `post.publishing_failed` | A post fails to publish to an account. Sent once per account. |
| `post.published_all` | A post is published to all its accounts. |
| `post.deleted` | One or more posts are deleted or moved to the trash. |
| `account.added` | A social account is connected. |
| `account.updated` | A social account is updated. |
| `account.deleted` | A social account is removed. |

There is no event for creating or editing a post.

## Payload

Every request has an `event` and a `data` object.

```json theme={null}
{
  "event": "post.published",
  "data": {
    "uuid": "…",
    "status": "published",
    "accounts": [ … ],
    "versions": [ … ],
    "account": { "id": 12, "provider": "linkedin", "external_url": "https://…" }
  }
}
```

* **Post events** send the post, in the same format as the [API](https://support.paddypost.com/api-reference/posts/get-post.md). `post.published` and `post.publishing_failed` also include the `account` it was sent to.
* **`post.deleted`** sends `uuids` (the deleted posts) and either `deleted: true` or `to_trash: true`.
* **`account.added` and `account.updated`** send the account.
* **`account.deleted`** sends the account's `uuid`.

Each request also has an `X-Request-Source` header.

## Verify the signature

If you set a secret, each request has an `X-Signature` header. It's an HMAC-SHA256 hash of the raw request body, made with your secret, in lowercase hex.

Compare it with your own hash of the raw body before you trust the request.

```js Node.js theme={null}
import crypto from "node:crypto";

function isValid(rawBody, signature, secret) {
  const expected = crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
  return signature?.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}
```

```php PHP theme={null}
$expected = hash_hmac('sha256', file_get_contents('php://input'), $secret);
$valid = hash_equals($expected, $_SERVER['HTTP_X_SIGNATURE'] ?? '');
```

```python Python theme={null}
import hmac, hashlib

def is_valid(raw_body: bytes, signature: str, secret: str) -> bool:
    expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature or "")
```

Use the raw body exactly as received. Parsing and re-encoding the JSON can change it and break the check.

To change the secret, edit the webhook and click **Change secret**.

## Retries

* A delivery succeeds when your URL replies with status 200, 201 or 202. Any other status, or no reply, is a failure.
* After a failure, PaddyPost tries again up to your **Max attempts**: 2 minutes later, then 4 minutes after that.
* Retries stop if you make the webhook inactive.

## Delivery log and resend

Open the webhook's menu and click **Webhook deliveries**. You can filter by **Succeeded** or **Failed**, and open a delivery to see the payload, your server's response and the next retry.

To send a delivery again, open it and click **Resend**. It is sent once, straight away, using the webhook's current settings.

Deliveries are kept for about a month.


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