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

Configures an Ash resource as an outbound webhook destination, including
its enable/disable state and references to signing secrets.

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

    # Map a declared :active boolean instead of injecting :status.
    endpoint do
      status_attribute :active
      enabled_values [true]
      disabled_value false
    end

The extension injects `url`, `status` (`:enabled | :disabled`), and four
secret references (`secret_ref` required,
`previous_secret_ref` / `legacy_secret_ref` / `legacy_previous_secret_ref`
for rotation and the legacy envelope). All four are
`AshHooks.Endpoint.SecretRef`. The type rejects secret-shaped literals
(`whsec_` / `whsk_` / `whpk_` prefixed material) at cast, on every write
path including consumer-defined actions: secrets live behind consumer
callbacks; store references to those secrets in the endpoint rows.

With `status_attribute` set, the extension uses that attribute instead of
injecting `status`. The dispatcher skips endpoints whose
mapped value is outside `enabled_values`, and the 410 auto-disable flips
the mapped attribute to `disabled_value`. The mapped attribute must be
declared by the consumer (fail-closed at compile).

The dispatcher skips non-enabled endpoints entirely (no delivery row).
URL casting checks the scheme, metadata hostnames, and literal IP addresses
on every write path. Send-time validation resolves hostnames and rejects
nonpublic addresses; the HTTP adapter pins the validated connection address.

Govern read access to target URLs and secret references with your own
resource policies. The package does not inject read policies.

Policy obligation: protect the injected `:disable` action wherever you
expose it to application callers. The 410 rule uses it as a system write
(`authorize?: false`). A permissive resource policy can otherwise allow
callers to disable endpoints. See `AshHooks.OutboundDelivery` for the
delivery ledger's action policy requirements.


## endpoint
Configuration of this resource as the outbound webhook endpoint.


### Nested DSLs
 * [auto_disable](#endpoint-auto_disable)





### Options

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`status_attribute`](#endpoint-status_attribute){: #endpoint-status_attribute } | `atom` |  | The consumer's enable/disable attribute the package maps onto (e.g. `active`). When set, `status` is not injected — the mapped attribute is the one durable switch: the dispatcher skips endpoints whose value is outside `enabled_values`, and the 410 auto-disable sets it to `disabled_value`. The attribute must be declared in the resource's own `attributes` block (not another extension's injection), and `enabled_values`/`disabled_value` must be spelled out explicitly — fail-closed at compile. |
| [`version_pinning`](#endpoint-version_pinning){: #endpoint-version_pinning } | `:off \| :on` | `:off` | Whether the payload-version pinning column is injected (default `:off` — existing schemas stay untouched). With `:on`, the extension injects `pinned_payload_version` (integer, nullable): an endpoint pinning a version its event's declaration carries (in `payload_versions`) receives THAT variant builder's bytes instead of the dispatch payload; a pin on an undeclared version fails the endpoint closed at dispatch. Declaring `:on` requires a migration for the column. |
| [`key_lifecycle`](#endpoint-key_lifecycle){: #endpoint-key_lifecycle } | `:off \| :on` | `:off` | Whether the signing-key lifecycle columns are injected (default `:off` — existing schemas stay untouched). With `:on`, the extension injects `secret_created_at`, `secret_first_used_at`, `secret_retired_at`, `previous_secret_created_at`, `previous_secret_first_used_at`, and `previous_secret_retired_at` (the scheduled — then actual — retirement of the old key), and `AshHooks.Endpoint.roll_secret/2` / `expire_previous_secret(s)/1,2` become available. Declaring `:on` requires a migration for the six columns. Timestamps only — never secret material. |
| [`response_capture_attributes`](#endpoint-response_capture_attributes){: #endpoint-response_capture_attributes } | `:off \| :on` | `:off` | Whether the per-endpoint response-capture columns are injected (default `:off` — existing schemas stay untouched). With `:on`, the extension injects `response_capture` (boolean, default `false`), `response_capture_max_bytes` (integer, default 2048), `response_capture_retention_seconds` (integer, default 30 days), and `response_header_allowlist` (string array, default none). Capture is still per ROW: an endpoint records response bodies in its attempt history only when its `response_capture` value is `true`. The captured bytes are bounded by the row's cap, pass the package's redaction floor, and only allowlisted response header names are kept. Declaring `:on` requires a migration for the four new columns. |
| [`enabled_values`](#endpoint-enabled_values){: #endpoint-enabled_values } | `list(any)` |  | Required with `status_attribute`: the mapped attribute's values that make the endpoint deliverable (e.g. `[true]`). A defaulted list against a boolean or custom-enum switch would silently match nothing — zero deliveries, no error — so the mapping refuses to compile without it. |
| [`disabled_value`](#endpoint-disabled_value){: #endpoint-disabled_value } | `any` |  | REQUIRED with `status_attribute`: the value the injected `:disable` action (and the 410 auto-disable) writes to the mapped attribute (e.g. `false`). |


### endpoint.auto_disable
The sustained-failure auto-disable policy, beside the 410 rule: the
health sweep (`AshHooks.EndpointHealth.sweep/3`) disables an endpoint
whose trailing failure window meets the configured failure share with
at least `min_attempts` of evidence — only on the sweep AFTER one
that warned (the declaration injects the `disable_warned_at` marker
column the warning sweep stamps; migrate it with the declaration).
Recovery below the warning band clears the marker. Re-enabling is an
explicit application action.







### Options

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`failure_window_seconds`](#endpoint-auto_disable-failure_window_seconds){: #endpoint-auto_disable-failure_window_seconds } | `pos_integer` | `3600` | The trailing window the failure share is computed over. |
| [`failure_share`](#endpoint-auto_disable-failure_share){: #endpoint-auto_disable-failure_share } | `any` | `0.95` | The failed-attempt share (0 < share <= 1) at or above which the window counts as sustained failure. |
| [`min_attempts`](#endpoint-auto_disable-min_attempts){: #endpoint-auto_disable-min_attempts } | `pos_integer` | `10` | Minimum attempts in the window before the policy may disable. |
| [`warning_share`](#endpoint-auto_disable-warning_share){: #endpoint-auto_disable-warning_share } | `any` |  | The warning threshold's failure share (default: `failure_share`). |
| [`warning_min_attempts`](#endpoint-auto_disable-warning_min_attempts){: #endpoint-auto_disable-warning_min_attempts } | `pos_integer` |  | Minimum attempts before a warning fires (default: half of `min_attempts`, at least 1). |









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