Skip to content

Implement Webhook Execution Service

Create service layer to execute webhook calls following the Standard Webhooks specification with bearer token authentication.

  • Method: async executeWebhook(integrationId: number, eventId?: string, userId: number)
  • Standard Webhooks headers: Content-Type, Authorization (Bearer), webhook-id, webhook-timestamp, webhook-signature (optional for MVP)
  • Body: { eventId, details } for event context mode; {} for default mode
  • Timeout: 30 seconds
  • Error handling: Log network errors, HTTP error codes, timeouts; throw to controller
  • Create WebhookExecutionLog before request; update after completion with response data and duration

Example:

Event Manager API call to get event details:

GET https://event-manager-api/events/{eventId}
Authorization: Bearer {event-manager-token}

Response:
{
  "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "details": {
    "employee_id": "12345",
    "action": "sync",
    "records_processed": 150
  },
  ...
}

Webhook POST request:

POST https://integration-platform.example.com/webhooks/adp-sync
Content-Type: application/json
Authorization: Bearer sk_live_abc123...
webhook-id: 550e8400-e29b-41d4-a716-446655440000
webhook-timestamp: 1699282800

{
  "eventId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "details": {
    "employee_id": "12345",
    "action": "sync",
    "records_processed": 150
  }
}