> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Outbound webhooks and strict HTTPS receipts

> Mount Standard Webhooks delivery or declare a fixed strict HTTPS effect receiver.

Mount `@bijectionhq/app-webhooks` to publish public events to registered
HTTPS receivers. Each endpoint has its own signing key. For an external
effect that needs durable acceptance or exclusion, use the fixed
[strict HTTPS receiver](#strict-https-effect-receivers).

To publish from a transactional event log, install a
[public event follower](https://docs.bijection.com/operations/events.md#follow-and-deliver) and use
`toWebhooks` with the mounted entry. It keeps the event's minted ID as
the Webhooks publication key.

## Install outbound delivery

```ts app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, mutation, role, t } from "@bijectionhq/bijection";
import { webhooks } from "@bijectionhq/app-webhooks";

const clerk = role({});
const hooks = webhooks({ publishers: [clerk] });
const admin = role({ clear: [hooks.endpointFamily.all], include: [hooks.operator], issue: true });

export const publishOrder = mutation({ allow: [clerk], args: { order: t.string } }, async (ctx, { order }) => {
  await ctx.call(hooks.events.publish, { type: "order.shipped", key: order, data: { order } });
  return null;
});

export const addOperator = mutation(
  { allow: [admin], under: hooks.endpointFamily.all, args: { to: t.principal } },
  async (ctx, { to }) => {
    await ctx.grant(hooks.operator, { to, under: hooks.endpointFamily.all });
    return null;
  },
);

export default app({ webhooks: hooks, clerk, admin, publishOrder, addOperator });
```

`webhooks(settings)` returns the app to place at a path of your tree.
Your code reaches only the exported functions of the apps it mounts, so
`events.publish` allows the roles you pass in `publishers`: your caller's
`clerk` grant admits the call. `access.grantOperator` and `access.revoke`
allow those you pass in `administrators`.
Your `admin` role includes the mount's `operator` role and carries `issue: true`,
so an admin grants it with `ctx.grant`, a grave act `bijection check` lists for `addOperator`. A holder of the mount's `operator` role calls
`webhooks.endpoints.register({ endpoint, url, events })`, then seals the
endpoint's `whsec_` signing key with `webhooks.endpoints.rotate`, called under
the label identified by the opaque `member` from `register` or `get`.
Until then its attempts refuse
`SigningKeyMissing`. The URL must use a public hostname over HTTPS on port
443\. Verify the `webhook-id`, `webhook-timestamp` and `webhook-signature`
headers with a Standard Webhooks verifier. See the
[Webhooks package API](https://github.com/bijectionhq/bijection/tree/main/npm-packages/apps/webhooks#api).

Public event data and a stable `(type, key)` identify a publication.
Retries can reach the receiver more than once, so deduplicate using the
envelope's `idempotency_key`. There are at most 64 endpoints per event
type and 64 types per endpoint. The default retry policy allows eight
attempts. A single delivery with a continuation has a deadline of at most three
days. Retirement fences deliveries under the old endpoint revision and
retains the key's revision record. Endpoint listing uses a page cursor
with up to 64 results. Delivery exposes no event stream cursor.

## Receiver delivery

HTTP sends carry `Bijection-Fencing-Token` and the stable idempotency key.
Use the key to deduplicate effects at the receiver. The default header is
`Idempotency-Key`. For a command whose reply can be lost, expose a separate
read-only operation that reports the original attempt's result. See
[Reconcile external results](https://docs.bijection.com/operations/reconciliation.md).

A receiver of a request carrying closable units declares `requests: { erase }`
or `requests: { retain, message }`. The named erase operation is a fixed
HTTP POST or DELETE. It receives `{ disclosures: string[] }` and confirms
deletion of those copies. A retention declaration records the finite duration
the provider accepts and the reviewed reason for relying on it.

## Wake a REST source from a provider webhook

The REST mount carries verified notification routes of its own: its `wakes`
subtree, built with `webhookWakes` from `@bijectionhq/app-webhooks/wake`.
Each provider has a `route.post("/webhooks/<provider>", providerVerifier)` reaction under the
mount's `data` label, and the mount declares each provider's verifying
secret at `<mount>.wakes.secrets.<provider>`. No separate Webhooks mount is
needed for incoming notifications.

For a REST mount at `source`, configure the provider to send HTTPS POSTs to
`/source/webhooks/<provider>` and set that provider's secret, bound to the
mount's route as the mount declares it. The following command reads the
Stripe signing secret from piped stdin.

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection secret set source.wakes.secrets.stripe \
  --app source --route "POST /webhooks/stripe"
```

| Route suffix | Secret path | Secret value |
| - | - | - |
| `stripe` | `source.wakes.secrets.stripe` | The endpoint signing secret Stripe issues |
| `shopify` | `source.wakes.secrets.shopify` | The Shopify app client secret used for HTTPS webhook HMAC |
| `github` | `source.wakes.secrets.github` | The webhook secret set on the repository or GitHub App |
| `hubspot` | `source.wakes.secrets.hubspot` | JSON with `secret` set to the HubSpot app client secret and `url` set to the exact HTTPS subscription URL |
| `zendesk` | `source.wakes.secrets.zendesk` | The webhook signing secret as shown in Zendesk |
| `slack` | `source.wakes.secrets.slack` | The Slack app signing secret |

HubSpot requires a v3 signature and a fixed route URL without query parameters
or percent escapes. Slack signs its Events API verification request. The
route answers the bounded URL verification challenge separately from wakes.
Signed timestamps must be within five minutes. The HTTP site accepts up to
128 KiB of notification bytes per request.

The verified request can bring forward the next poll for the matching
provider on that mount. It changes a due time or records one pending wake
during an existing poll. The source respects its active state, pause,
continuity gaps and failure backoff. Each poll reads from the same retained
position and lands data using the same record, edge or event keys.
Notification bodies, provider IDs and cursors never enter the guest, and
requests with repeated signatures can only schedule more polling. Ordinary
polls continue on schedule when notifications are missed. Each source's
polling scope, visibility delays, deletion rules and retention still apply.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.