# Connect events and webhooks

> Index of all OmniSocials docs pages: https://docs.omnisocials.com/llms.txt

Connect sends events to your server: an account that connects or needs a new sign-in, a post that publishes or fails, and messages for your customers. You register a webhook endpoint once, for all your customers.

:::note
These are the webhooks of the Connect API. The `/v1/webhooks` endpoints of the OmniSocials API, with their own signature, are not open to Connect keys.
:::

## Create a webhook endpoint

```bash
curl -X POST https://sandbox-api.omnisocials.com/connect/v1/webhook-endpoints \
  -H "Authorization: Bearer $OMNISOCIALS_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "url": "https://api.example.com/webhooks/omnisocials", "events": [] }'
```

- `events: []` means every event. To receive fewer, list the types you want.
- The answer includes `secret` (`whsec_…`) once. Store it on your server, for example as `OMNISOCIALS_WEBHOOK_SECRET`. If you lose it, roll the secret in the console under **Webhooks**.
- Register the final URL: redirects are not followed.

## Event types

| Type | When |
|------|------|
| `account.connected` | A customer connected an account |
| `account.needs_reconnect` | An account needs a new sign-in. Create a connect link for that network, see [Reconnects](https://docs.omnisocials.com/connect/connect-links.md#reconnects) |
| `account.reconnected` | An account that needed a new sign-in works again |
| `account.disconnected` | An account was disconnected |
| `post.scheduled` | A post was scheduled |
| `post.published` | A post was published |
| `post.failed` | A post failed |
| `post.approved` | A post was approved |
| `post.rejected` | A post was rejected |
| `notification.requested` | A message for your customer, for you to deliver |

## The body

```json
{
  "id": "evt_…",
  "type": "notification.requested",
  "created_at": "2026-11-02T07:00:00Z",
  "livemode": false,
  "customer": { "id": "cust_…", "external_id": "hc-1042" },
  "data": {
    "subject": "…",
    "text": "…",
    "action_url": "https://connect.omnisocials.com/c/…"
  }
}
```

- `livemode` is `false` in the sandbox and `true` on live.
- `customer` names the customer by both ids, so you can find it in your own database by `external_id`.
- `data` depends on the type. Post events carry the post's id in `data.post_id`; read the post with `GET /v1/posts/{id}` and the customer header.

## notification.requested

This event carries a message for your customer: `data.subject`, `data.text` and `data.action_url`, for example a reconnect link. Send it by email, SMS or in your product. OmniSocials never contacts your customers.

## Verify the signature

Every request is signed the [Standard Webhooks](https://www.standardwebhooks.com) way, with the headers `webhook-id`, `webhook-timestamp` and `webhook-signature`. Verify it with the `standardwebhooks` package (npm, PyPI), your secret and the raw request body. Parse the JSON only after the check passes: a body that was parsed and serialized again may not match the signature.

## Answer fast

- Answer `2xx` within 10 seconds, and do slow work after you answered.
- The whole answer must arrive within 15 seconds and be at most 1 MB. A slower or larger answer, or a redirect, counts as a failed attempt.
- A failed delivery is tried again for about a day.
- The same event can arrive twice. Keep the `id` of each event you handled, and skip an `id` you have seen before.

## Send a test event

```bash
curl -X POST https://sandbox-api.omnisocials.com/connect/v1/webhook-endpoints/<endpoint_id>/test \
  -H "Authorization: Bearer $OMNISOCIALS_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "type": "account.needs_reconnect" }'
```

The endpoint receives a sample event of that type with `"test": true`. Use it to test the parts of your handler that the sandbox does not trigger on its own, such as a reconnect.

In the sandbox, a test account that connects sends `account.connected`. The console shows every event and delivery under **Logs** for 30 days.
