Nera.Lib.Webhook 1.0.1

dotnet add package Nera.Lib.Webhook --version 1.0.1
                    
NuGet\Install-Package Nera.Lib.Webhook -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nera.Lib.Webhook" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nera.Lib.Webhook" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Nera.Lib.Webhook" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nera.Lib.Webhook --version 1.0.1
                    
#r "nuget: Nera.Lib.Webhook, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nera.Lib.Webhook@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nera.Lib.Webhook&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Nera.Lib.Webhook&version=1.0.1
                    
Install as a Cake Tool

Nera.Lib.Webhook

A comprehensive webhook handling library for .NET applications, providing webhook reception, processing, and management capabilities with priority-based processing and background job support.

Features

  • Webhook Reception: Receive and validate incoming webhook requests
  • Priority Processing: Support for High/Normal/Low priority webhooks
  • Background Processing: Quartz.NET integration for background job processing
  • Database Storage: Entity Framework Core integration with PostgreSQL support
  • Retry Logic: Automatic retry with exponential backoff for failed webhooks
  • Event Publishing: Integration events for webhook lifecycle
  • Auto Migration: Automatic database schema migration
  • Comprehensive APIs: Full CRUD operations and statistics

Quick Start

1. Install the Package

<PackageReference Include="Nera.Lib.Webhook" Version="1.0.0" />

2. Configure Services

// In Program.cs or Startup.cs
builder.Services
    .AddWebhookServices(builder.Configuration)
    .AddWebhookDbContext(connectionString);

3. Create Webhook Endpoint

[ApiController]
[Route("api/webhooks")]
public class WebhookController : ControllerBase
{
    private readonly IWebhookReceiver _webhookReceiver;

    public WebhookController(IWebhookReceiver webhookReceiver)
    {
        _webhookReceiver = webhookReceiver;
    }

    [HttpPost("receive")]
    public async Task<IActionResult> ReceiveWebhook(
        [FromHeader(Name = "X-Event-Type")] string eventType,
        [FromHeader(Name = "X-Priority")] string? priority = null)
    {
        var webhookId = await _webhookReceiver.ReceiveWebhookAsync(
            Request, 
            eventType, 
            "your-source",
            priority != null && Enum.TryParse<WebhookPriority>(priority, true, out var p) ? p : WebhookPriority.Normal);

        return Ok(new { WebhookId = webhookId });
    }
}

4. Configure Database

// Connection string should point to your database
var connectionString = "Host=localhost;Port=5432;Database=yourdb;Username=user;Password=pass";

Configuration

Webhook Options

{
  "Webhook": {
    "DefaultPriority": "Normal",
    "MaxRetryAttempts": 3,
    "RetryIntervalMinutes": 5,
    "SignatureHeaderName": "X-Hub-Signature",
    "EnableAutoMigration": true
  }
}

Environment Variables

ENV_CONNECTION_STRING=Host=localhost;Port=5432;Database=webhookdb;Username=user;Password=pass

Priority System

  • High/Critical: Processed immediately upon receipt
  • Normal: Queued for background processing
  • Low: Queued for background processing with lower priority

Database Schema

The library creates a webhook schema with the following table:

  • WebhookEvents: Stores all webhook events with processing status, retry information, and metadata

API Endpoints

The library provides comprehensive APIs for webhook management:

  • GET /api/webhooks/{id} - Get webhook details
  • GET /api/webhooks - List webhooks with filtering
  • GET /api/webhooks/statistics - Get webhook statistics
  • POST /api/webhooks/{id}/retry - Retry failed webhook

Integration Events

The library publishes the following integration events:

  • WebhookReceivedEvent: When a webhook is received
  • WebhookProcessedEvent: When a webhook is processed (success or failure)

Background Processing

Webhooks are processed by Quartz.NET jobs that run every 30 seconds by default. You can configure the schedule in the WebhookQuartzConfiguration.

Error Handling

  • Automatic retry with exponential backoff
  • Dead letter queue for permanently failed webhooks
  • Comprehensive error logging
  • Status tracking for all webhook events

Examples

See the Example.Webhook project for complete implementation examples.

License

MIT License - see LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 111 10/18/2025
1.0.0 212 9/9/2025