Implement Webhook API Endpoints
Create REST API endpoints for managing webhook configurations and triggering webhook execution.
- Config endpoints (Admin/Super Admin only):
GET /integrations/:id/webhook- get config (authToken masked)POST /integrations/:id/webhook- create config (webhookUrl must be HTTPS)PATCH /integrations/:id/webhook- update configDELETE /integrations/:id/webhook- soft delete- Trigger endpoint:
POST /integrations/:id/trigger(requirescanTriggerIntegrationspermission) - Body:
{ eventId?: string }- if provided, fetch event details as payload - Returns: executionLogId, statusCode, responseBody, duration
- History endpoints (Admin/Super Admin only):
GET /integrations/:id/webhook/executions- paginated listGET /webhook/executions/:executionId- full execution details
Example:
Trigger webhook with event context:
POST /integrations/123/trigger
{
"eventId": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
}
Response 200 OK:
{
"executionLogId": "550e8400-e29b-41d4-a716-446655440000",
"statusCode": 200,
"responseBody": {"status": "success", "jobId": "abc123"},
"executionDurationMs": 245
}
Trigger webhook without context:
POST /integrations/123/trigger
Response 200 OK:
{
"executionLogId": "660e8400-e29b-41d4-a716-446655440001",
"statusCode": 202,
"responseBody": {"status": "accepted"},
"executionDurationMs": 180
}