Skip to main content

Webhooks

Subscribe to events and receive signed HTTP POST requests at your HTTPS endpoints in real time. Manage endpoints and audit deliveries in the dashboard under Settings → Developer / API.

Authoritative Event Catalog​

Event NameDescription
message.createdEmitted when an inbound or outbound message is created across any channel (WhatsApp, Telegram, Facebook, Instagram, Livechat, Email).
message.updatedEmitted on delivery status changes (e.g. sent, delivered, read) across supported channels.
conversation.createdEmitted when a new conversation thread is initiated.
conversation.status_changedEmitted when a conversation is resolved, snoozed, or reopened.
session.createdEmitted when a new agent chat session is initialized.
session.assignedEmitted when a session is assigned to an agent or team.
session.transferredEmitted when a session is transferred between agents or teams.
session.resolvedEmitted when a chat session is resolved.
session.reopenedEmitted when a customer re-engages on a previously resolved session.
channel.connectedEmitted when an omnichannel communication channel is connected.
channel.disconnectedEmitted when a communication channel is disconnected or revoked.
contact.createdEmitted when a new customer/contact record is created.
contact.updatedEmitted when contact details or custom attributes change.

Signature Verification (HMAC-SHA256)​

Every webhook delivery includes cryptographic headers so your servers can verify the payload originates from Relasi.U and has not been tampered with or replayed:

  • X-Relasi-Webhook-Id: Unique event identifier (e.g., evt_01J9ABC...).
  • X-Relasi-Timestamp: Delivery timestamp in ISO 8601 / RFC 3339 UTC format (e.g. 2026-11-03T10:15:30Z).
  • X-Relasi-Signature: Versioned signature string: v1=<base64-encoded-hmac>.
  • X-Relasi-Event: Event name (e.g., message.created).

Verification Algorithm​

The signature is computed over:

<eventID>.<unixEpochSeconds>.<body>

where unixEpochSeconds is parsed from the X-Relasi-Timestamp header (or epoch seconds integer), signed using your endpoint's signing secret (whsec_...) with HMAC-SHA256.

Node.js Example​

import crypto from "crypto";

export function verifyRelasiWebhook({ payloadRawBody, secret, headers }) {
const webhookId = headers["x-relasi-webhook-id"];
const timestampHeader = headers["x-relasi-timestamp"];
const signatureHeader = headers["x-relasi-signature"];

if (!webhookId || !timestampHeader || !signatureHeader) {
throw new Error("Missing required Relasi webhook headers");
}

// Parse RFC3339 timestamp into epoch seconds
const tsEpoch = Math.floor(new Date(timestampHeader).getTime() / 1000);
const now = Math.floor(Date.now() / 1000);

// Guard against replay attacks (e.g., reject if older than 5 minutes)
if (Math.abs(now - tsEpoch) > 300) {
throw new Error("Webhook timestamp expired or outside tolerance window");
}

const expectedSignature =
"v1=" +
crypto
.createHmac("sha256", secret)
.update(`${webhookId}.${tsEpoch}.${payloadRawBody}`)
.digest("base64");

const valid = crypto.timingSafeEqual(
Buffer.from(signatureHeader),
Buffer.from(expectedSignature)
);

if (!valid) {
throw new Error("Invalid signature");
}

return true;
}

Python (FastAPI / Flask) Example​

import hmac
import hashlib
import base64
import time
from datetime import datetime, timezone

def verify_relasi_signature(secret: str, raw_body: bytes, webhook_id: str, timestamp_header: str, signature: str) -> bool:
try:
# Support RFC3339 string format
dt = datetime.fromisoformat(timestamp_header.replace("Z", "+00:00"))
ts_epoch = int(dt.timestamp())
except ValueError:
ts_epoch = int(timestamp_header)

# 5-minute replay window
if abs(int(time.time()) - ts_epoch) > 300:
return False

signed_content = f"{webhook_id}.{ts_epoch}.".encode("utf-8") + raw_body
computed = "v1=" + base64.b64encode(
hmac.new(secret.encode("utf-8"), signed_content, hashlib.sha256).digest()
).decode("utf-8")

return hmac.compare_digest(computed, signature)

Public Webhook Payload Schemas​

Relasi.U webhook payloads wrap the domain object inside a standard PublicEvent envelope (id, type, api_version, created_at, app_id, data). Sensitive data (such as access tokens, session keys, and API secrets) are strictly excluded.

message.created​

{
"id": "evt_01J9ABC...",
"type": "message.created",
"api_version": "2026-06-01",
"created_at": "2026-11-03T10:15:30.123Z",
"app_id": "664fa1...",
"data": {
"id": "6720ab...",
"conversation_id": "6710ab...",
"session_id": "6715cd...",
"channel_id": "6701ef...",
"direction": "inbound",
"type": "text",
"content": "Hello, I need assistance with my order #9821.",
"status": "delivered",
"is_ai_reply": false,
"created_at": "2026-11-03T10:15:30Z",
"customer": {
"id": "670a...",
"name": "Jane Doe",
"phone": "+628123456789",
"email": "jane@example.com",
"avatar_url": "https://cdn.relasiu.com/avatars/jane.png"
},
"channel": {
"id": "6701ef...",
"type": "whatsapp_business",
"name": "Customer Support WhatsApp",
"phone_number": "+628111222333"
},
"media": [
{
"type": "document",
"url": "https://pub.relasiu.com/media/doc.pdf",
"filename": "order_receipt.pdf",
"mime_type": "application/pdf",
"size": 1048576
}
],
"actor": {
"type": "customer",
"id": "670a...",
"name": "Jane Doe"
}
}
}

Field Reference for message.created​

FieldTypeDescription
idstringUnique ObjectID of the message.
conversation_idstringConversation thread identifier.
session_idstring (optional)Active agent session identifier.
channel_idstringUnique channel identifier.
directionstringinbound (customer message) or outbound (sent to customer).
typestringMessage payload format (text, image, video, audio, document, etc.).
contentstringText body or caption.
statusstringMessage delivery state (sent, delivered, read, failed).
is_ai_replybooleantrue if generated by the workspace AI assistant; false for human-agent outbound messages and customer inbound messages.
created_atstring (ISO-8601)Timestamp of message creation.
customerobject (optional)Safe customer context summary.
channelobject (optional)Safe channel context summary.
mediaarray (optional)Normalized media attachments.
actorobject (optional)Context on who initiated the message (customer, agent, api, system).

message.updated​

{
"id": "evt_01J9ABD...",
"type": "message.updated",
"api_version": "2026-06-01",
"created_at": "2026-11-03T10:16:00Z",
"app_id": "664fa1...",
"data": {
"message_id": "6720ab...",
"conversation_id": "6710ab...",
"session_id": "6715cd...",
"channel_id": "6701ef...",
"customer_id": "670a...",
"status": "read",
"previous_status": "delivered",
"timestamp": "2026-11-03T10:16:00Z",
"actor": {
"type": "customer",
"id": "670a...",
"name": "Jane Doe"
},
"customer": {
"id": "670a...",
"name": "Jane Doe",
"phone": "+628123456789"
},
"channel": {
"id": "6701ef...",
"type": "whatsapp_business",
"name": "Customer Support WhatsApp"
}
}
}

session.assigned / session.transferred / session.resolved​

{
"id": "evt_01J9XYZ...",
"type": "session.assigned",
"api_version": "2026-06-01",
"created_at": "2026-11-03T10:20:00Z",
"app_id": "664fa1...",
"data": {
"session_id": "672...",
"number": 1402,
"number_label": "#1402",
"conversation_id": "671...",
"channel_id": "670...",
"customer_id": "670a...",
"status": "assigned",
"previous_status": "open",
"topic": "Billing inquiry",
"assigned_to": "664...",
"assigned_by": "663...",
"customer": {
"id": "670a...",
"name": "Jane Doe",
"phone": "+628123456789"
},
"channel": {
"id": "670...",
"type": "whatsapp_business",
"name": "Customer Support WhatsApp"
},
"created_at": "2026-11-03T10:10:00Z",
"updated_at": "2026-11-03T10:20:00Z"
}
}

channel.connected / channel.disconnected​

{
"id": "evt_01J9DEF...",
"type": "channel.connected",
"api_version": "2026-06-01",
"created_at": "2026-11-03T10:25:00Z",
"app_id": "664fa1...",
"data": {
"channel_id": "670...",
"type": "whatsapp_business",
"name": "Sales WhatsApp Main",
"phone_number": "+628111999888",
"is_active": true,
"timestamp": "2026-11-03T10:25:00Z"
}
}

Delivery Retries & Resilience​

  • Retry schedule: Non-2xx responses or network timeouts (>10s) are retried with exponential backoff: ~1m, 5m, 30m, 2h, 5h, 10h up to a maximum of 8 attempts.
  • Circuit breaker: Endpoints with consecutive failures are marked as disabled to prevent cascading failure. You can re-enable them in the dashboard once fixed.
  • Idempotency & Deduplication: Receiver endpoints must be idempotent. Deduplicate on X-Relasi-Webhook-Id or event_id.
  • Manual Redelivery: Inspect failed delivery records and trigger on-demand retries directly in the dashboard under Settings → Developer / API → Webhook History.