> For the complete documentation index, see [llms.txt](https://tsanet.gitbook.io/connect/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tsanet.gitbook.io/connect/api-reference/webhook-events.md). Agents can also search and read this documentation through its [MCP server](https://tsanet.gitbook.io/connect/~gitbook/mcp).

# Webhook Events

Outbound webhook events delivered by Connect 2 to your registered HTTPS endpoint.

Connect 2 delivers outbound webhook events to your registered HTTPS endpoint.

## Your endpoint

Connect 2 POSTs every event to the callback URL you registered, for example `https://api.example.com/webhooks/connect`. It must be reachable over HTTPS in production.

## Payload versions

| Version         | Endpoint            | Events                                          | Format                             |
| --------------- | ------------------- | ----------------------------------------------- | ---------------------------------- |
| **V1** (legacy) | `POST /v1/webhooks` | `collaboration-request.created`, `note.created` | Flat JSON                          |
| **V2**          | `POST /v2/webhooks` | All 5 event types                               | CloudEvents 1.0 structured binding |

{% hint style="warning" %}
V1 is frozen — no new events or fields will ever be added. Use `POST /v2/webhooks` to receive the full event set with CloudEvents-formatted payloads.
{% endhint %}

## Event types (V2)

| CloudEvent `type`                                           | Fired when                                                                               | `data` fields                |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------- |
| `org.tsanet.connect.collaboration-request.created`          | A new collaboration request is submitted                                                 | `requestToken`               |
| `org.tsanet.connect.collaboration-request.closed`           | A collaboration request is closed                                                        | `requestToken`               |
| `org.tsanet.connect.collaboration-request.note.created`     | A note is added to a collaboration request                                               | `requestToken`, `noteToken`  |
| `org.tsanet.connect.collaboration-request.response.created` | A response is created: approval, rejection, information request, or information response | `requestToken`, `responseId` |
| `org.tsanet.connect.collaboration-request.response.updated` | An existing response record is revised                                                   | `requestToken`, `responseId` |

For `response.created`, check `data.responseType` to determine the specific response type.

### `data` fields

| Field          | Type            | Description                                                                                                                             |
| -------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `requestToken` | string          | Public token identifying the collaboration request. Example: `tok_abc123`                                                               |
| `noteToken`    | string          | Public token identifying the note. Example: `tok_note456`                                                                               |
| `responseId`   | integer (int64) | Internal ID of the response record. Fetch the full response via the Connect 2 REST API to get type, status, and details. Example: `789` |

## V2 payload (CloudEvents envelope)

Every V2 event uses the same envelope. Only `type` and `data` differ between event types.

| Field             | Type               | Description                                                                                                                                      |
| ----------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `specversion`     | string             | CloudEvents specification version. Always `1.0`.                                                                                                 |
| `id`              | string (uuid)      | Stable event identifier. Reused across broker redeliveries — safe to use as an idempotency key. Also present in the `X-Connect-Delivery` header. |
| `source`          | string             | URI identifying Connect 2 as the event producer. Varies by environment — see [Source identifier](#source-identifier).                            |
| `type`            | string             | CloudEvent type. Also present in the `X-Connect-Event` header.                                                                                   |
| `time`            | string (date-time) | ISO 8601 UTC timestamp of when the event occurred.                                                                                               |
| `datacontenttype` | string             | Always `application/json`.                                                                                                                       |
| `subscriptionid`  | integer (int64)    | The ID of the webhook subscription this event was delivered to. Useful when multiple subscriptions point to the same endpoint.                   |
| `data`            | object             | Event data — see [`data` fields](#data-fields).                                                                                                  |

All fields except `data` are required.

{% code title="org.tsanet.connect.collaboration-request.note.created" %}

```json
{
  "specversion": "1.0",
  "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "source": "https://connect2.tsanet.us",
  "type": "org.tsanet.connect.collaboration-request.note.created",
  "time": "2024-01-15T10:30:00.000Z",
  "datacontenttype": "application/json",
  "subscriptionid": 42,
  "data": {
    "requestToken": "tok_abc123",
    "noteToken": "tok_note456"
  }
}
```

{% endcode %}

## V1 payloads (legacy)

V1 payloads are flat JSON. All fields are required.

| Event                           | Fields                                                |
| ------------------------------- | ----------------------------------------------------- |
| `collaboration-request.created` | `eventType`, `requestToken`, `timestamp`              |
| `note.created`                  | `eventType`, `requestToken`, `noteToken`, `timestamp` |

`timestamp` is an ISO 8601 UTC timestamp of when the event occurred.

{% code title="note.created (V1)" %}

```json
{
  "eventType": "note.created",
  "requestToken": "tok_abc123",
  "noteToken": "tok_note456",
  "timestamp": "2024-01-15T10:30:00.000Z"
}
```

{% endcode %}

## Delivery headers

| Header                | V2       | V1       | Value                                                                                                                            |
| --------------------- | -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `Content-Type`        | ✅        | ✅        | `application/cloudevents+json` (V2) or `application/json` (V1)                                                                   |
| `X-Hub-Signature-256` | required | required | `sha256=<64 hex chars>` — HMAC-SHA256 of the raw request body using your subscription secret                                     |
| `X-Connect-Delivery`  | required | —        | The CloudEvent `id`. Identical to the `id` field in the body. Use for idempotency checks or correlating delivery logs.           |
| `X-Connect-Event`     | required | —        | The CloudEvent `type`. Identical to the `type` field in the body. Useful for routing at the HTTP layer without parsing the body. |

## Verifying signatures

Every delivery includes an `X-Hub-Signature-256` header containing an HMAC-SHA256 signature of the **raw request body** using your subscription secret:

```
X-Hub-Signature-256: sha256=<64 hex chars>
```

Always verify this before processing the payload. Your subscription secret is returned **once**, on creation. It cannot be rotated: to change it, delete the subscription (`DELETE /v1/webhooks/{id}`) and create a new one.

## Delivery guarantees

* **At-least-once.** Your endpoint may receive the same event more than once. Use the CloudEvent `id` (V2) or `requestToken` + `eventType` + `timestamp` (V1) for idempotency.
* **Retries.** `5xx` responses and network timeouts trigger broker-level redelivery. **Two retries are attempted, with a 1-hour delay between each.** `4xx` responses are treated as permanent failures and not retried.
* **Timeout.** Your endpoint must respond within **30 seconds**.
* **Dead-letter.** After the third failed attempt, the delivery is moved to a dead-letter queue and is not attempted again automatically. Each attempt is recorded as its own row in the delivery log (`GET /v1/webhooks/{id}/deliveries`). Contact TSANet support about dead-lettered deliveries.

## Subscription filters

Subscriptions may filter deliveries by `eventTypes`, `caseDirections`, and `partnerCompanyIds`. Omitting `caseDirections` or `partnerCompanyIds` means that filter is not applied.

Directions are relative to the company that owns the subscription:

* `INBOUND` — that company **receives** the case.
* `OUTBOUND` — that company **submits** it.

## Source identifier

The CloudEvent `source` field identifies the environment that sent the event:

| Environment | `source`                       |
| ----------- | ------------------------------ |
| Production  | `https://connect2.tsanet.us`   |
| Beta        | `https://connect2.tsanet.net`  |
| Dev         | `https://connect2.tahoelab.us` |
