Skip to content

Convoy Integration

LTG API Portal uses Convoy as the webhook delivery engine. Convoy handles retries, dead-letter queues, endpoint health tracking, and delivery logs.

Architecture

Portal API ──→ Convoy Server (port 5005)
│
├── PostgreSQL (event storage)
├── Redis (queue)
└── Convoy Agent (delivery worker)
│
├──→ Endpoint A (https://acme.com/webhooks)
├──→ Endpoint B (https://beta.com/events)
└──→ Test Listener (/api/webhooks/receive/:id)

Event types

The portal emits these event types (and you can define your own):

Event When fired
subscription.created New subscription issued
subscription.revoked Subscription cancelled
product.published Product set to active
agent.run.completed Agent run finished
job.run.completed Scheduled job finished

Custom event types can be dispatched via POST /api/webhooks/dispatch.

Endpoint security

Convoy signs every delivery with an HMAC-SHA256 signature using the endpoint’s secret:

X-Convoy-Signature: t=1705312800,v1=abc123...

To verify in your receiver:

import crypto from 'crypto';
function verifySignature(payload: string, header: string, secret: string): boolean {
const [tPart, vPart] = header.split(',');
const timestamp = tPart.split('=')[1];
const signature = vPart.split('=')[1];
const signed = `${timestamp}.${payload}`;
const expected = crypto.createHmac('sha256', secret).update(signed).digest('hex');
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}

Retry policy

Convoy retries failed deliveries with exponential backoff:

Attempt Delay
1 Immediate
2 5 seconds
3 30 seconds
4 5 minutes
5 30 minutes

After 5 failed attempts, the delivery moves to the dead-letter queue. Manually retry from the portal or via API.

Convoy configuration

The Convoy instance is pre-configured via docker-compose. To access the Convoy dashboard directly, the API is available at port 5005.

Key environment variables:

CONVOY_HOST=http://convoy-server:5005
CONVOY_API_KEY=default-key
CONVOY_PROJECT_ID=default-project

Fan-out to multiple endpoints

Each event is delivered to all endpoints subscribed to that event type. Convoy handles the fan-out — you just dispatch once:

Terminal window
POST /api/webhooks/dispatch
{
"eventType": "subscription.created",
"payload": { "subscriptionId": "sub_abc", "name": "Acme Corp" }
}

All endpoints that subscribed to subscription.created (or with an empty events list = all events) receive the delivery.