Current section

Files

Jump to
ash_hooks README.md
Raw

README.md

<!--
SPDX-FileCopyrightText: © 2026 BaseLabs Holdings LLC

SPDX-License-Identifier: MIT
-->

[![CI](https://github.com/baselabs/ash_hooks/actions/workflows/ci.yml/badge.svg)](https://github.com/baselabs/ash_hooks/actions/workflows/ci.yml)
[![Hex](https://img.shields.io/hexpm/v/ash_hooks.svg)](https://hex.pm/packages/ash_hooks)
[![HexDocs](https://img.shields.io/badge/docs-HexDocs-purple)](https://hexdocs.pm/ash_hooks)
[![REUSE](https://api.reuse.software/badge/github.com/baselabs/ash_hooks)](https://api.reuse.software/info/github.com/baselabs/ash_hooks)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit)

# AshHooks

AshHooks adds inbound and outbound webhooks to [Ash Framework](https://hexdocs.pm/ash) resources.

- Verify incoming signatures over the original request bytes before calling a handler.
- Deduplicate receipts with a database ledger that records handler outcomes and supports retry.
- Sign outgoing deliveries with [Standard Webhooks](https://www.standardwebhooks.com/) and persist per-endpoint retry state.
- Read delivery and attempt history under your Ash domain's authorization policy.

## Install

In an Ash application with Igniter, run:

<!-- not-run: The installer changes the dependencies, formatter, and endpoint of the adopter's project. -->
```sh
mix igniter.install ash_hooks
```

Before compiling resources, set `config :ash, default_string_length_count: :codepoints`
in your application's `config/config.exs`.

## Receive a webhook

With the ledger and provider from [Get started](documentation/tutorials/get-started.md#verify-and-handle-an-incoming-event),
pass the original body, request headers, and the ledger's required scope.

<!-- not-run: This call needs the registered ledger, provider, and a real signed request. -->
```elixir
AshHooks.Ingress.ingest(MyApp.WebhookLedger, :orders, raw_body, %{
  headers: request_headers,
  scope: %{account_id: account_id}
})
```

## Documentation

Tutorials ([Get started](documentation/tutorials/get-started.md) · [Livebook](documentation/livebooks/get-started.livemd)) · [Topics](documentation/topics/delivery/delivery-lifecycle.md) · [How-to](documentation/how-to/index.md) · [Reference](documentation/dsls/DSL-AshHooks.md)

See [Compatibility](documentation/topics/support/compatibility.md) for supported runtimes and dependencies.

## License

[MIT](https://opensource.org/license/mit).