Skip to main content

Events

Guardhouse sends webhook events as JSON envelopes. Event types and payloads are part of the Guardhouse server webhook contract, not a single SDK.

Validate the signature first, then deserialize and dispatch the event body.

Envelope

{
"EventType": 1,
"Data": {
"UserId": 123,
"Email": "[email protected]",
"FirstName": "John",
"LastName": "Doe"
},
"Timestamp": 1777036800
}
FieldTypeDescription
EventTypeintegerNumeric webhook event type.
DataobjectEvent-specific payload.
TimestampintegerUnix timestamp, in seconds, generated for the delivery.

Event Types

ValueEventPayload
1UserCreatedUser payload
2UserUpdatedUser payload

User Payload

UserCreated and UserUpdated currently use the same payload shape.

{
"UserId": 123,
"Email": "[email protected]",
"FirstName": "John",
"LastName": "Doe"
}
FieldTypeDescription
UserIdintegerGuardhouse user identifier.
EmailstringUser email address.
FirstNamestringUser first name.
LastNamestringUser last name.

Receiver Example

using System.Text.Json;
using Guardhouse.SDK.Webhooks;

app.MapPost("/webhooks/guardhouse", async (HttpRequest request, IConfiguration configuration) =>
{
var secret = configuration["Guardhouse:Webhooks:Secret"];
if (string.IsNullOrWhiteSpace(secret))
{
return Results.StatusCode(StatusCodes.Status500InternalServerError);
}

var isValid = await GuardhouseWebhookSignatureValidator.IsValidAsync(request, secret);
if (!isValid)
{
return Results.BadRequest("Signature verification failed.");
}

var envelope = await request.ReadFromJsonAsync<JsonElement>();

// Inspect EventType and deserialize Data to the matching event payload.
return Results.Ok();
});

SDK Notes

SDKs may expose helper APIs for triggering webhook workflows or validating signatures, but the event list above is the webhook delivery contract.

Do not process the webhook body before validating X-Hub-Signature.