Webhooks
Webhooks Reference
Receive, verify, and handle real-time HTTP event notifications from TGCPilot.
Overview #
Webhooks allow your systems to receive real-time HTTP notifications whenever significant events occur in your TGCPilot workspace, such as customer inbound messages, conversation assignment changes, or contact updates.
Endpoints can be registered via the workspace dashboard or programmatically using POST /api/v1/webhook-endpoints (requires the webhooks:manage permission scope).
HTTPS Required
Delivery Headers #
Every webhook delivery attempt includes six standard HTTP request headers:
| Header | Description |
|---|---|
X-TGCPilot-Event |
The dot-notated event name identifying the occurrence type (e.g. message.inbound). |
X-TGCPilot-Delivery |
Unique UUID for this event delivery. Reused across retry attempts. Use this value to deduplicate incoming payloads. |
X-TGCPilot-Timestamp |
Unix epoch timestamp in seconds indicating when the event originally occurred. |
X-TGCPilot-Signature-256 |
HMAC-SHA256 signature computed over the raw request body string using your endpoint signing secret. |
X-TGCPilot-Api-Version |
The TGCPilot webhook API version for the payload format (currently 2026-11-11). |
User-Agent |
Fixed User-Agent header value identifying the delivery engine.
TGCPilot-Webhooks/1
|
Payload Envelope #
All webhook event deliveries share a consistent top-level JSON structure with resource metadata and origin context:
id— Stable UUID identifier for this event occurrence.type— The event type string matching X-TGCPilot-Event.occurred_at— ISO-8601 UTC timestamp of the change.api_version— The webhook API version contract.workspace— Object containing the workspace id.origin— Origin context object containing surface, connection_id, api_key_id, and correlation_id.data— Event-specific payload object. Message and conversation events include channel and participant. Message events include provider_message_id. Contact events include identities.data.resource— Resource locator within data identifying the primary subject (type and id).
Sample Delivery Envelope
{
"id": "b4d5e0c1-2f7a-5c39-8d1e-6a0f3c9b7e12",
"type": "message.inbound",
"occurred_at": "2026-10-18T09:15:02+03:00",
"api_version": "2026-11-11",
"test": false,
"workspace": {
"id": "acme"
},
"origin": {
"surface": "inbound",
"connection_id": null,
"api_key_id": null,
"correlation_id": null
},
"data": {
"conversation_id": 77,
"message_id": 901,
"type": "text",
"preview": "مرحبا، أريد معرفة حالة طلبي",
"received_at": "2026-10-18T09:14:58+03:00",
"resource": {
"type": "message",
"id": "901"
},
"channel": {
"type": "whatsapp",
"account_id": "01K0AAA0000000000000000000",
"account_label": "+965 5000 0111"
},
"participant": {
"id": "01K0AAB0000000000000000000",
"display_name": "Fatima",
"external_id": "96555000111",
"external_id_label": "WhatsApp number"
},
"provider_message_id": "wamid.HBgLOTY1NTUwMDAxMTEVAgASGBQzQTdG"
}
}
Event Types #
The following table lists all 11 supported webhook events, their associated automation read scopes, and emission triggers:
| Event | Read scope for automations | Emitted when |
|---|---|---|
contact.created |
contacts:read
|
A contact is created from the app, the API, or a first inbound message. |
contact.updated |
contacts:read
|
A single contact changes; data.changed_fields lists what changed. |
message.read |
— | A customer reads an outbound message (read receipt). |
message.delivered |
— | An outbound message is delivered to the recipient device. |
message.inbound |
messages:read
|
A customer message is received (bounded preview, never media or history). |
conversation.new |
conversations:read
|
A new conversation starts. |
conversation.assigned |
conversations:read
|
A conversation is claimed, assigned, handed off, or released (data.action). |
conversation.closed |
conversations:read
|
Every conversation that is closed, including each one closed by a bulk close. |
template.status_changed |
— | A message template approval status changes (approved, rejected, paused). |
system.error |
— | A system or service failure occurs in the workspace. |
subscription.gate_transition |
— | The workspace subscription tier or feature gating changes. |
Signature Verification #
Verify the authenticity and integrity of each delivery by computing an HMAC-SHA256 hash of the exact raw HTTP request body using your endpoint's secret, then comparing it against the X-TGCPilot-Signature-256 header using a timing-safe equality comparison.
Replay Protection & Deduplication
Computed Verification Example
Endpoint Secret: example-secret-do-not-use
sha256=e796fac1185db11e562ab0da1e7103eb390e34d38d46f86301a443d61c19f204
Code Examples
$signature = $request->header('X-TGCPilot-Signature-256');
$rawBody = $request->getContent();
$expected = 'sha256=' . hash_hmac('sha256', $rawBody, $secret);
if (! hash_equals($expected, (string) $signature)) {
abort(401, 'Invalid signature');
}
const crypto = require('crypto');
function verifyWebhook(rawBody, signatureHeader, secret) {
const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
const received = Buffer.from(signatureHeader || '', 'utf8');
const computed = Buffer.from(expected, 'utf8');
return received.length === computed.length && crypto.timingSafeEqual(received, computed);
}
import hashlib
import hmac
def verify_webhook(raw_body: bytes, signature_header: str, secret: str) -> bool:
expected = 'sha256=' + hmac.new(secret.encode('utf-8'), raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature_header or '')
Retries, Timeouts & Dead-Letter Handling #
Webhook deliveries execute asynchronously. Endpoints should acknowledge receipt with an HTTP 2xx status code as quickly as possible. Requests time out after 10 seconds, and HTTP redirects are never followed.
If an endpoint responds with a retryable HTTP status (408, 429, or 5xx) or suffers a network timeout, TGCPilot automatically retries delivery up to 5 attempts according to the following schedule:
Retry Schedule
| Attempt | Delay |
|---|---|
| #1 | 60 seconds (with runtime jitter) |
| #2 | 300 seconds (with runtime jitter) |
| #3 | 900 seconds (with runtime jitter) |
| #4 | 1800 seconds (with runtime jitter) |
Retry-After Support
When an endpoint responds with 429 and includes a valid numeric Retry-After header in seconds, TGCPilot notes it in the attempt record. Client errors other than 408 and 429 (such as 400, 401, 403, 404, or 410) are treated as definitive permanent failures and will not be retried.
Automatic Pausing
To prevent cascading failures, if an endpoint fails consecutively across 5 distinct events, TGCPilot automatically pauses the endpoint and alerts workspace managers.
Secret Rotation #
You can rotate your endpoint signing secret at any time from the workspace developer portal or API. Rotating a secret generates a new 48-character cryptographic string displayed once.
Secret rotation is immediate: the previous secret is replaced on the endpoint record and immediately stops verifying any new or retried deliveries. There is no grace window or dual-secret overlap. Update your receiving verification service promptly before or immediately after rotation.
Warning