TrimLynk External Integrations Framework
The TrimLynk External Integrations Framework allows TrimLynk workspace events (link creations, clicks, leads, sales, campaigns) to be streamed securely and asynchronously to external automation platforms (Zapier, Make) and team collaboration tools (Slack, Discord).
1. Architecture Overview
The integration layer sits on top of TrimLynk's internal event bus without introducing parallel queues or altering the core link redirection and attribution pipelines.
TrimLynk Application Event
(Click, Lead, Sale, Link, Campaign)
│
▼
Webhook Dispatcher Bus
(server/lib/webhook-dispatcher.cjs)
│
┌─────────────┴─────────────┐
▼ ▼
Native Custom Webhooks Integration Dispatcher
(Standard HTTP POST + HMAC) (server/lib/integrations/integration-dispatcher.cjs)
│
┌─────────────────────┼─────────────────────┐
▼ ▼ ▼
Slack Adapter Discord Adapter Zapier / Make Adapters
(Block Kit Payload) (Embed Payload) (Normalized JSON + HMAC)
│ │ │
▼ ▼ ▼
Slack Channel Discord Server Zapier / Make WebhooksCore Components
| Component | Path | Responsibility |
|---|---|---|
| Provider Registry | server/lib/integrations/integration-registry.cjs | Central catalog of supported providers, metadata, validation rules, payload formatters, and capabilities. |
| Integration Service | server/lib/integrations/integration-service.cjs | Multi-tenant CRUD operations, workspace BOLA isolation, synthetic test event triggers, delivery logs. |
| Integration Dispatcher | server/lib/integrations/integration-dispatcher.cjs | Non-blocking async event matching, outbound network dispatching, exponential backoff retries, and delivery logging. |
| Security Layer | server/lib/integrations/integration-security.cjs | AES-256-GCM secret encryption at rest, SSRF destination validation (safeFetch), workspace rate limits. |
| Provider Adapters | server/lib/integrations/providers/ | Provider-specific transformers: slack.cjs, discord.cjs, zapier.cjs, make.cjs. |
2. Supported Providers
| Provider | ID | Category | Auth / Transport | Capabilities |
|---|---|---|---|---|
| Slack | slack | Team Chat | Slack Incoming Webhook | incoming_webhook, test, blocks_formatting |
| Discord | discord | Community Chat | Discord Webhook URL | incoming_webhook, test, embeds_formatting |
| Zapier | zapier | No-Code Automation | Catch Hook + Optional HMAC | webhook, test, hmac_signature |
| Make | make | Visual Workflows | Custom Webhook + Optional HMAC | webhook, test, hmac_signature |
3. Authoritative Event Catalog
TrimLynk emits normalized events across all integrations using the authoritative event envelope:
| Event Type | Trigger | Key Payload Fields |
|---|---|---|
click.created | Short link receives an attributed visitor click | urlId, slug, originalUrl, country, city, device, browser, referer |
lead.created | Lead conversion recorded (signup, form submit) | urlId, slug, leadId, eventName, customerRef, metadata |
sale.created | Purchase or checkout conversion attributed | urlId, slug, saleId, amount, currency, orderId, commission |
conversion.created | General conversion attribution milestone | urlId, slug, conversionType, amount, metadata |
link.created | New short link created in workspace | urlId, slug, shortUrl, originalUrl, domain, campaignId |
link.updated | Short link updated or destination edited | urlId, slug, originalUrl, previousUrl |
campaign.created | New campaign organized | campaignId, name, slug, description |
campaign.updated | Campaign budget, goal, or tags updated | campaignId, name, updatedFields |
integration.test | Synthetic verification ping from dashboard | message, timestamp, environment |
4. Standard Event Envelope
Zapier and Make integrations receive the normalized event envelope:
{
"id": "evt_clx9abc1234567890",
"type": "sale.created",
"createdAt": "2026-09-24T18:30:00.000Z",
"workspaceId": "team_abc123",
"integrationId": "int_xyz789",
"provider": "zapier",
"data": {
"urlId": "lnk_98765",
"slug": "spring-sale",
"shortUrl": "https://lynk.to/spring-sale",
"originalUrl": "https://example.com/products/sale",
"amount": 99.00,
"currency": "USD",
"orderId": "ord_55412",
"country": "US",
"source": "facebook"
}
}Traceability & Idempotency
id: Unique, immutable event ID generated at creation. Retained across all delivery attempts and retries.deliveryId: Unique delivery attempt ID recorded inIntegrationDelivery.- Idempotent consumers can deduplicate using
id.
5. Security & Privacy Guarantees
Strict SSRF Protection
All user-configured webhook destinations are validated using server/lib/safe-fetch.cjs and integration-security.cjs:
- Protocol: Only
https://is permitted in production environments (http://permitted in local dev only). - IP Address Blacklist: RFC 1918 private subnets (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16), loopbacks (127.0.0.1,localhost), link-local (169.254.0.0/16), and IPv6 loopback (::1) are strictly rejected. - Cloud Metadata Endpoints: Blocked (
169.254.169.254,metadata.google.internal). - DNS Rebinding Protection: Addresses resolved via DNS before connecting and verified against blacklists.
Zero Plaintext Secrets (AES-256-GCM)
- Webhook URLs and HMAC secrets are encrypted at rest in the database using
AES-256-GCMwith random initialization vectors (IV) and auth tags. - Secrets and tokens are never returned by
GET /api/v1/integrationsor logged in audit tables. URLs are masked ashttps://hooks.slack.com/services/T00.../B00.../••••••••.
PII Sanitization
- Passwords, JWTs, API keys, email addresses, and raw authentication cookies are strictly stripped from outgoing payloads before formatting.
Rate Limiting
- Each workspace is restricted to a maximum burst rate of 120 delivery attempts per minute across all external integrations to prevent runaway recursion or external provider API throttling.
6. Asynchronous Delivery & Retry Backoff
External notifications are non-blocking: short-link redirects and conversion recordings complete in sub-5ms without waiting for Slack, Discord, or Zapier HTTP responses.
Retry Schedule
If an external provider returns a transient error (408, 429, 500, 502, 503, 504) or experiences a connection timeout, TrimLynk attempts up to 5 retries with exponential backoff:
| Attempt | Delay | Backoff Strategy |
|---|---|---|
| Attempt 1 | Immediate | 0s |
| Attempt 2 | +30 seconds | Exponential |
| Attempt 3 | +2 minutes | Exponential |
| Attempt 4 | +10 minutes | Exponential |
| Attempt 5 | +30 minutes | Final retry |
Retry-After Header Respect
If the destination server returns an HTTP 429 Too Many Requests with a valid Retry-After header (in seconds or HTTP date format), the scheduler honors the exact requested delay (capped at 1 hour).
Permanent Client Failures
HTTP 400 Bad Request, 401 Unauthorized, 403 Forbidden, and 404 Not Found responses are considered non-transient configuration errors. The delivery is marked as failed immediately without unnecessary retries.
7. Developer API Reference
All integration management endpoints require authentication via Bearer JWT or scoped API Key (integrations:read, integrations:write).
Endpoints
| Method | Endpoint | Required Scope | Description |
|---|---|---|---|
GET | /api/v1/integrations | integrations:read | List all configured integrations in workspace |
POST | /api/v1/integrations | integrations:write | Create a new integration |
GET | /api/v1/integrations/providers | integrations:read | List supported integration providers and metadata |
GET | /api/v1/integrations/events | integrations:read | List supported event types |
GET | /api/v1/integrations/:id | integrations:read | Get integration details (secrets masked) |
PATCH | /api/v1/integrations/:id | integrations:write | Update name, URL, secret, or event subscriptions |
DELETE | /api/v1/integrations/:id | integrations:write | Remove an integration |
POST | /api/v1/integrations/:id/enable | integrations:write | Enable an integration |
POST | /api/v1/integrations/:id/disable | integrations:write | Pause an integration |
POST | /api/v1/integrations/:id/test | integrations:write | Send a synthetic test event |
GET | /api/v1/integrations/:id/deliveries | integrations:read | View delivery history and attempts |
POST | /api/v1/integrations/:id/deliveries/:deliveryId/retry | integrations:write | Manually re-attempt a failed delivery |
Create Integration Example
curl -X POST https://api.trimlynk.com/api/v1/integrations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "slack",
"name": "Marketing Team Alerts",
"config": {
"webhookUrl": "https://hooks.slack.com/services/T00/B00/XXXXX"
},
"eventSubscriptions": ["click.created", "lead.created", "sale.created"]
}'8. Troubleshooting
| Status Code | Cause | Resolution |
|---|---|---|
400 Invalid URL | The destination URL failed SSRF validation or scheme check. | Verify the URL begins with https:// and is publicly reachable. Internal IPs (127.0.0.1, 10.x.x.x) are rejected. |
403 Forbidden | API key lacks required scope. | Generate an API key with integrations:read and integrations:write scopes in Developer Portal. |
404 Integration Not Found | Integration ID does not exist or belongs to another workspace. | Verify workspace ownership (BOLA protection prevents cross-tenant access). |
429 Rate Limit Exceeded | Workspace exceeded 120 integration dispatches/min. | Stagger high-volume event spikes or filter event subscriptions to essential types only. |