# Webhooks (/growsocmed/docs/developers/webhooks)

Signed HTTP notifications when accounts connect, posts publish or fail, comments and DMs arrive, and automations run.

Instead of polling, add a webhook endpoint: GrowSocmed sends a `POST` to your URL when something happens in the workspace. Webhooks are managed by workspace owners and admins, in the dashboard (**Developer** → **Webhooks**) or through the API.

## Add an endpoint [#add-an-endpoint]

```bash
curl -X POST https://socmed.growpaces.com/api/v1/webhooks \
  -H "Authorization: Bearer gs_..." \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/hooks/grow-socmed","events":["post.published","post.failed","comment.created"]}'
```

The URL must be a public `https://` address. The response contains the signing `secret` (`whsec_…`), shown only this once.

## Events [#events]

| Event | Sent when |
| --- | --- |
| `account.connected` | A social account was connected, or connected again (reconnected: true). |
| `account.expired` | An account needs reconnecting (its access ended at the platform). |
| `account.disconnected` | An account was disconnected, in GrowSocmed or from the platform's side. |
| `post.published` | A post went out on one account (one event per account). |
| `post.failed` | A post failed on one account for good (after its retries). |
| `comment.created` | Someone commented on one of the accounts' posts. |
| `comment.replied` | The account replied to a comment (from GrowSocmed, an automation or the platform's app). |
| `comment.hidden` | A comment was hidden. |
| `comment.unhidden` | A hidden comment was shown again. |
| `comment.deleted` | A comment was deleted. |
| `message.received` | A DM arrived. |
| `message.sent` | A DM was sent by the account (from GrowSocmed, an automation or the platform's app). |
| `automation.run` | An automation finished a run: sent, skipped or failed, with the reason. |

`webhook.test` is sent only by the test button and [`POST /webhooks/{id}/test`](/growsocmed/docs/api-reference/webhooks/test-webhook). Comment and message events are sent only for things under 24 hours old (a sync that finds older ones stays quiet).

## The request [#the-request]

```http
POST /hooks/grow-socmed HTTP/1.1
Content-Type: application/json
User-Agent: GrowSocmed-Webhook/1
Grow-Event: post.published
Grow-Delivery: 0193a7c2-…
Grow-Signature: t=1763600000,v1=5d41402abc4b2a76b9719d911017c592…

{
  "id": "0193a7c2-…",
  "type": "post.published",
  "created_at": "2026-11-20T02:00:00.000Z",
  "workspace_id": "3f1c…",
  "data": {
    "post_id": "…", "target_id": "…", "account_id": "…", "platform": "instagram",
    "platform_post_id": "…", "permalink": "https://www.instagram.com/p/…", "published_at": "2026-11-20T02:00:00.000Z"
  }
}
```

`id` is the event's id: the same event sent again (a retry or a resend) keeps its id, so use it to ignore duplicates. `data` depends on the event; account events carry `account` (`id`, `platform`, `username`, `display_name`, `status`), comment events carry the comment, its post and author, and `automation.run` carries the run's `status` and `reason`.

## Verify the signature [#verify-the-signature]

`Grow-Signature` is `t=<unix seconds>,v1=<hex>` where `v1` is HMAC-SHA256, keyed with your endpoint's secret, of the string `<t>.<raw body>`. Compute it over the raw body exactly as received, compare in constant time, and reject old timestamps (for example older than five minutes).

```ts
import { createHmac, timingSafeEqual } from 'node:crypto';

export function verify(rawBody: string, header: string, secret: string, toleranceSec = 300) {
  const parts = Object.fromEntries(header.split(',').map((p) => p.split('=') as [string, string]));
  const t = Number(parts.t);
  if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;
  const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
  const given = Buffer.from(parts.v1 ?? '', 'hex');
  const want = Buffer.from(expected, 'hex');
  return given.length === want.length && timingSafeEqual(given, want);
}
```

## Answering and retries [#answering-and-retries]

Answer with any `2xx` within 5 seconds; do slow work after answering. Redirects are not followed. A delivery that fails (timeout, connection error, non-2xx) is tried again after 1, 5, 30, 120, 300, 480 and 480 minutes: 8 attempts over about a day.

After 50 failed deliveries in a row the endpoint is turned off and its creator gets an email; events that happen while it is off are not kept. Turn it on again with [`PATCH /webhooks/{id}`](/growsocmed/docs/api-reference/webhooks/update-webhook) (`active: true`).

[`GET /webhooks/{id}/deliveries`](/growsocmed/docs/api-reference/webhooks/list-webhook-deliveries) shows the deliveries of the last 30 days with the response status and body, and [`POST /webhooks/{id}/deliveries/{deliveryId}/resend`](/growsocmed/docs/api-reference/webhooks/resend-webhook-delivery) sends one again now. Test sends and resends are limited to 60 an hour per workspace.