TrimLynk Docs

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.

text
               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 Webhooks

Core Components

ComponentPathResponsibility
Provider Registryserver/lib/integrations/integration-registry.cjsCentral catalog of supported providers, metadata, validation rules, payload formatters, and capabilities.
Integration Serviceserver/lib/integrations/integration-service.cjsMulti-tenant CRUD operations, workspace BOLA isolation, synthetic test event triggers, delivery logs.
Integration Dispatcherserver/lib/integrations/integration-dispatcher.cjsNon-blocking async event matching, outbound network dispatching, exponential backoff retries, and delivery logging.
Security Layerserver/lib/integrations/integration-security.cjsAES-256-GCM secret encryption at rest, SSRF destination validation (safeFetch), workspace rate limits.
Provider Adaptersserver/lib/integrations/providers/Provider-specific transformers: slack.cjs, discord.cjs, zapier.cjs, make.cjs.

2. Supported Providers

ProviderIDCategoryAuth / TransportCapabilities
SlackslackTeam ChatSlack Incoming Webhookincoming_webhook, test, blocks_formatting
DiscorddiscordCommunity ChatDiscord Webhook URLincoming_webhook, test, embeds_formatting
ZapierzapierNo-Code AutomationCatch Hook + Optional HMACwebhook, test, hmac_signature
MakemakeVisual WorkflowsCustom Webhook + Optional HMACwebhook, test, hmac_signature

3. Authoritative Event Catalog

TrimLynk emits normalized events across all integrations using the authoritative event envelope:

Event TypeTriggerKey Payload Fields
click.createdShort link receives an attributed visitor clickurlId, slug, originalUrl, country, city, device, browser, referer
lead.createdLead conversion recorded (signup, form submit)urlId, slug, leadId, eventName, customerRef, metadata
sale.createdPurchase or checkout conversion attributedurlId, slug, saleId, amount, currency, orderId, commission
conversion.createdGeneral conversion attribution milestoneurlId, slug, conversionType, amount, metadata
link.createdNew short link created in workspaceurlId, slug, shortUrl, originalUrl, domain, campaignId
link.updatedShort link updated or destination editedurlId, slug, originalUrl, previousUrl
campaign.createdNew campaign organizedcampaignId, name, slug, description
campaign.updatedCampaign budget, goal, or tags updatedcampaignId, name, updatedFields
integration.testSynthetic verification ping from dashboardmessage, timestamp, environment

4. Standard Event Envelope

Zapier and Make integrations receive the normalized event envelope:

json
{
  "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 in IntegrationDelivery.
  • 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-GCM with random initialization vectors (IV) and auth tags.
  • Secrets and tokens are never returned by GET /api/v1/integrations or logged in audit tables. URLs are masked as https://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:

AttemptDelayBackoff Strategy
Attempt 1Immediate0s
Attempt 2+30 secondsExponential
Attempt 3+2 minutesExponential
Attempt 4+10 minutesExponential
Attempt 5+30 minutesFinal 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

MethodEndpointRequired ScopeDescription
GET/api/v1/integrationsintegrations:readList all configured integrations in workspace
POST/api/v1/integrationsintegrations:writeCreate a new integration
GET/api/v1/integrations/providersintegrations:readList supported integration providers and metadata
GET/api/v1/integrations/eventsintegrations:readList supported event types
GET/api/v1/integrations/:idintegrations:readGet integration details (secrets masked)
PATCH/api/v1/integrations/:idintegrations:writeUpdate name, URL, secret, or event subscriptions
DELETE/api/v1/integrations/:idintegrations:writeRemove an integration
POST/api/v1/integrations/:id/enableintegrations:writeEnable an integration
POST/api/v1/integrations/:id/disableintegrations:writePause an integration
POST/api/v1/integrations/:id/testintegrations:writeSend a synthetic test event
GET/api/v1/integrations/:id/deliveriesintegrations:readView delivery history and attempts
POST/api/v1/integrations/:id/deliveries/:deliveryId/retryintegrations:writeManually re-attempt a failed delivery

Create Integration Example

bash
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 CodeCauseResolution
400 Invalid URLThe 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 ForbiddenAPI key lacks required scope.Generate an API key with integrations:read and integrations:write scopes in Developer Portal.
404 Integration Not FoundIntegration ID does not exist or belongs to another workspace.Verify workspace ownership (BOLA protection prevents cross-tenant access).
429 Rate Limit ExceededWorkspace exceeded 120 integration dispatches/min.Stagger high-volume event spikes or filter event subscriptions to essential types only.

Ready to test in your workspace?

Manage API keys, live webhooks, and request telemetry in the TrimLynk Developer Console.

Manage Integrations