Skip to content

Webhooks

A webhook forwards events Chronicle observes to an external HTTP endpoint — use it to notify another system without that system needing to connect to Chronicle itself. Webhooks are configured server-side (the Kernel makes the HTTP calls), so registering one is a one-time setup step, not something you do per request.

using Cratis.Chronicle;
using Cratis.Chronicle.Events;
using Cratis.Chronicle.Webhooks;
[EventType]
public record WebhooksIndexAccountOpened(string OwnerName);
public class WebhooksIndexRegister(IEventStore eventStore)
{
public async Task RegisterWebhook() =>
await eventStore.Webhooks.Register(
"account-events",
"https://example.com/chronicle/webhooks",
builder => builder
.WithEventType<WebhooksIndexAccountOpened>()
.WithHeader("x-source", "my-app")
.WithBearerToken(Environment.GetEnvironmentVariable("WEBHOOK_TOKEN")!));
}

If no event types are configured, the webhook forwards every event type registered for the client.

using Cratis.Chronicle;
using Cratis.Chronicle.Webhooks;
public class WebhooksIndexQuery(IEventStore eventStore)
{
public async Task<IEnumerable<WebhookDefinition>> GetAllWebhooks() => await eventStore.Webhooks.GetAll();
}

Kotlin and Java don’t currently have a webhooks API — there’s no equivalent anywhere in the Kotlin client SDK yet.

  • Jobs — inspecting and controlling long-running Kernel operations, the other kernel-managed background concern.
  • Subscriptions — forwarding events between event stores rather than to an external HTTP endpoint.