<!--
This file was generated by Spark. Do not edit it by hand.
-->
# AshHooks.Subscription

<a id="AshHooks-Subscription"></a>

Turns the consumer's resource into the outbound Subscription, specifying which
events go to which endpoint, and with which signature envelope.


<!-- not-run: This subscription fragment requires a host endpoint resource and data layer configuration. -->

    use Ash.Resource,
      data_layer: AshSqlite.DataLayer,
      extensions: [AshHooks.Subscription]

    subscription do
      endpoint_resource(MyApp.WebhookEndpoint)
    end

The extension injects: `event_types` (`{:array, :string}`, default
`["*"]`), `endpoint_id` (uuid, the sole UUID-storage-compatible primary
key of the `endpoint_resource`, under any attribute name), and `signing_mode`
(`:legacy | :dual | :standard`, NULLABLE, with the outbound declaration's mode
applying when unset). A subscription's own
primary key follows the same single UUID-storage-compatible contract because
outbound delivery rows store it in `subscription_id`. UUIDv7 keys satisfy
this contract. Composite and non-UUID keys fail at DSL compilation with the
reference column named in the error.

With `pausable :on`, the extension also injects `paused` (boolean,
nonnullable, default `false`). The dispatcher skips paused subscriptions
before creating delivery rows. Existing delivery rows continue to deliver:
pausing is not cancellation. Applications pause and resume through their own
ordinary update actions and policies. Opting in requires a migration for
the `paused` column; the default `:off` adds no attribute or schema requirement.

## Typing contract

Events carry string types. You can declare `event_types` yourself,
including as an array of constrained atoms. Your declaration replaces the
generated attribute, including its constraints and default. Atom and string
entries match the same event names. The bare `"*"` or `:"*"` entry matches
all event names.

Matching is exact strings plus the bare wildcard entry, evaluated IN
MEMORY by the dispatcher after reading through the consumer's primary
read action. There is no array-containment SQL, so the semantics are identical
on every data layer.

The package injects NO read action and NO read policies: read surfaces
are the consumer's to open through their own domain policies; internal
dispatcher reads bypass authorization; application policies govern exposed reads.


## subscription
Configuration of this resource as the outbound subscription.







### Options

<table><thead><tr><th style="text-align: left;">Name</th><th style="text-align: left;">Type</th><th style="text-align: left;">Default</th><th style="text-align: left;">Docs</th></tr></thead><tbody><tr><td style="text-align: left;"><a class="spark-required" href="#subscription-endpoint_resource" id="subscription-endpoint_resource"><code class="inline">endpoint_resource</code></a> <strong>required</strong></td><td style="text-align: left;"><code class="inline">atom</code></td><td style="text-align: left;"></td><td style="text-align: left;">The resource module carrying <code class="inline">AshHooks.Endpoint</code> that <code class="inline">endpoint_id</code> references. The dispatcher loads endpoint records through it and calls <code class="inline">AshHooks.Endpoint.enabled?/1</code> to decide whether they receive delivery rows.</td></tr><tr><td style="text-align: left;"><a href="#subscription-pausable" id="subscription-pausable"><code class="inline">pausable</code></a></td><td style="text-align: left;"><code class="inline">:off | :on</code></td><td style="text-align: left;"><code class="inline">:off</code></td><td style="text-align: left;">Whether the subscription pause column is injected (default <code class="inline">:off</code>, leaving existing schemas untouched). With <code class="inline">:on</code>, the extension injects <code class="inline">paused</code> (boolean, nonnullable, default <code class="inline">false</code>). The dispatcher skips paused subscriptions before creating delivery rows; existing delivery rows are unaffected. Applications pause and resume through ordinary updates of <code class="inline">paused</code> under their own actions and policies. Declaring <code class="inline">:on</code> requires a migration for the column.</td></tr><tr><td style="text-align: left;"><a href="#subscription-filter_attributes" id="subscription-filter_attributes"><code class="inline">filter_attributes</code></a></td><td style="text-align: left;"><code class="inline">list(atom)</code></td><td style="text-align: left;"><code class="inline">[]</code></td><td style="text-align: left;">The closed set of EVENT ATTRIBUTE names subscriptions may filter on (e.g. <code class="inline">[:order_id, :region]</code>). Declaring a nonempty list injects the <code class="inline">event_filters</code> column (<code class="inline">:map</code>, nullable): a subscription whose filters all match the dispatching event's metadata receives the delivery. Filters are evaluated BEFORE any delivery row is created. A filter key outside this set never matches (fail closed); a list value matches any-of. Requires a migration for the column.</td></tr></tbody></table>







<style type="text/css">.spark-required::after { content: "*"; color: red !important; }</style>
