> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.scaleabm.org/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.scaleabm.org/_mcp/server.

# Webhooks

> Receive real-time events for messages, connections, engagement, and session health

# Webhooks

Voyager can push real-time events to your server via webhooks. Instead of polling for new messages or connection requests, configure a webhook URL and Voyager will POST events as they happen. Payloads are signed with HMAC-SHA256, and Slack-formatted delivery is built in.

> **Note**
>
> Management endpoints return the `{ success, statusCode, message, data, errors }` envelope. The JSON examples below show only the endpoint-specific payload — access `res.data.<field>` in your client. Webhook *deliveries* to your server use the raw event shape below, not the envelope.

## Create a Webhook

```bash
curl -X POST "$BASE/api/webhooks" \
  -H "Authorization: Bearer $KEY" \
  -H "X-User-Id: $USER" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhook",
    "events": ["message_received", "connection_received", "session_expired"],
    "secret": "your-hmac-secret"
  }'
```

```json
{
  "success": true,
  "webhook": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "url": "https://your-server.com/webhook",
    "events": ["message_received", "connection_received", "session_expired"],
    "secret": "***",
    "active": true,
    "createdAt": "2026-03-17T10:00:00Z",
    "updatedAt": "2026-03-17T10:00:00Z"
  }
}
```

Note: `id` is a UUID, and the `secret` you sent is masked to `"***"` in every response — Voyager never echoes it back. Save it on your side when you create the webhook.

## Available Event Types

### Inbound Signals

| Event                 | Description                     |
| --------------------- | ------------------------------- |
| `message_received`    | New message in your inbox       |
| `connection_received` | New inbound connection request  |
| `post_liked`          | Someone liked your post         |
| `post_commented`      | Someone commented on your post  |
| `comment_replied`     | Someone replied to your comment |

### Action Results

| Event                      | Description                  |
| -------------------------- | ---------------------------- |
| `action_send_completed`    | Message send succeeded       |
| `action_send_failed`       | Message send failed          |
| `action_connect_completed` | Connection request succeeded |
| `action_connect_failed`    | Connection request failed    |
| `action_like_completed`    | Like action succeeded        |
| `action_comment_completed` | Comment action succeeded     |
| `action_post_completed`    | Post creation succeeded      |
| `action_visit_completed`   | Profile visit succeeded      |

### System Events

| Event             | Description                                       |
| ----------------- | ------------------------------------------------- |
| `session_expired` | LinkedIn session expired, needs re-authentication |
| `job_completed`   | Async job finished successfully                   |
| `job_failed`      | Async job failed                                  |

## Payload Format

All webhook payloads follow this structure:

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "event": "message_received",
  "tenantId": "32e365dc-e8c4-4caa-8637-0e6b48dfeccd",
  "tenantName": "Acme",
  "timestamp": "2026-03-17T10:30:00Z",
  "data": {
    "userId": "charis",
    "conversationId": "conv123",
    "participantName": "Jane Smith",
    "participantUrn": "urn:li:fsd_profile:ACoAA...",
    "lastMessage": "Thanks for connecting! Would love to chat about..."
  }
}
```

* `id` is a UUID per delivery — useful for idempotency on your side
* `event` is one of the types in the catalogue above
* `tenantName` is the human-readable tenant label
* `data` varies by event type; the `userId` of the LinkedIn account the event belongs to lives inside `data` (not at the top level)

## HMAC Signature Verification

Voyager signs every webhook payload with HMAC-SHA256 using the `secret` you provided at creation. The signature is in the `X-Webhook-Signature` header.

### Verification Example (Node.js)

```javascript
const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

// In your webhook handler
app.post('/webhook', (req, res) => {
  const sig = req.headers['x-webhook-signature'];
  if (!verifyWebhook(req.body, sig, 'your-hmac-secret')) {
    return res.status(401).send('Invalid signature');
  }
  // Process the event
  console.log(req.body.event, req.body.data);
  res.status(200).send('OK');
});
```

> **Warning**
>
> Always verify the HMAC signature before processing webhook payloads. Without verification, an attacker could send fake events to your endpoint.

## Slack-Native Formatting

If your webhook URL points to a Slack incoming webhook (`hooks.slack.com`), Voyager automatically formats payloads as Slack messages with rich formatting -- no middleware needed.

```bash
curl -X POST "$BASE/api/webhooks" \
  -H "Authorization: Bearer $KEY" \
  -H "X-User-Id: $USER" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://hooks.slack.com/services/T.../B.../xxx",
    "events": ["message_received", "connection_received", "session_expired"]
  }'
```

> **Tip**
>
> For Slack webhooks, you do not need to provide a `secret` -- Slack handles authentication via the webhook URL itself. Voyager detects `hooks.slack.com` URLs and switches to Slack message format automatically.

### Recommended Channel Split

For production setups, use two webhooks:

1. **Main channel** -- inbound signals: `message_received`, `connection_received`, `post_liked`, `post_commented`, `comment_replied`, `session_expired`
2. **Test/ops channel** -- action results: `action_send_completed`, `action_send_failed`, `action_connect_completed`, `action_connect_failed`, `job_completed`, `job_failed`

This prevents test runs and action confirmations from drowning out real inbound signals.

## List Webhooks

```bash
curl "$BASE/api/webhooks" \
  -H "Authorization: Bearer $KEY" \
  -H "X-User-Id: $USER"
```

## Delete a Webhook

```bash
curl -X DELETE "$BASE/api/webhooks/<webhookId>" \
  -H "Authorization: Bearer $KEY" \
  -H "X-User-Id: $USER"
```

## Test a Webhook

Send a test payload to verify your endpoint is working:

```bash
curl -X POST "$BASE/api/webhooks/<webhookId>/test" \
  -H "Authorization: Bearer $KEY" \
  -H "X-User-Id: $USER"
```

## Delivery Log

Check recent delivery attempts and their HTTP status codes:

```bash
curl "$BASE/api/webhooks/deliveries" \
  -H "Authorization: Bearer $KEY" \
  -H "X-User-Id: $USER"
```

## How Events Are Generated

Voyager's background PollService checks for new messages, connection requests, and notifications every 5 minutes per tenant. When it detects changes, it fires the corresponding webhook events.

The first poll after a session sync takes a state snapshot without firing events -- this prevents a flood of historical events on first connect. Only subsequent polls emit deltas.

> **Note**
>
> If all three poll sections (messages, invitations, notifications) fail simultaneously with session errors, Voyager emits a `session_expired` event and pauses polling for that user until the next cookie sync.

## Related

* [Sessions](/guides/core-concepts/sessions-cookies) -- Session expiry and recovery
* [Messaging](/guides/core-concepts/messaging) -- Message events
* [Connections](/guides/core-concepts/connections) -- Connection events