---
name: supabase-webhooks-events
description: 'Implement Supabase database webhooks, pg_net async HTTP, LISTEN/NOTIFY,

  and Edge Function event handlers with signature verification.

  Use when setting up database webhooks for INSERT/UPDATE/DELETE events,

  sending HTTP requests from PostgreSQL triggers, handling Realtime

  postgres_changes as an event source, or building event-driven architectures.

  Trigger with phrases like "supabase webhook", "database events",

  "pg_net trigger", "supabase LISTEN NOTIFY", "webhook signature verify",

  "supabase event-driven", "supabase_functions.http_request".'
allowed-tools: Write, Bash(supabase:*), Bash(curl:*), Bash(psql:*)
version: 1.55.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
  - saas
  - supabase
  - webhooks
  - events
  - triggers
  - pg_net
  - realtime
compatibility: Designed for Claude Code
title: supabase-webhooks-events
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events
last_updated: 2026-11-01T03:01:42.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/database-webhooks.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/database-webhooks.md), [references/edge-function-receivers.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/edge-function-receivers.md), [references/errors.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/errors.md), [references/event-handler-pattern.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/event-handler-pattern.md), [references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/examples.md), [references/listen-notify-realtime.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/listen-notify-realtime.md), [references/signature-verification.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/signature-verification.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/supabase-webhooks-events`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/supabase-webhooks-events`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/supabase-webhooks-events --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/supabase-webhooks-events --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Supabase Webhooks and Database Events

## Overview

Choose Database Webhooks/pg_net for configured outbound HTTP, LISTEN/NOTIFY for
lightweight database notifications, or Realtime Postgres Changes for UI updates.
These mechanisms have different durability, authentication, replay and failure
contracts. This skill's concrete signed receiver illustrates accepted inbox
INGESTION, not complete business processing or exactly-once delivery.

## Prerequisites

- A reviewed producer/receiver contract and intended project identity
- Reviewed migrations, endpoint configuration and secret provisioning
- A durable producer event ID/outbox if reliable signed ingestion is required
- An explicitly authorized deployment workflow; reading this skill deploys nothing

## Authentication

Native Database Webhooks send the HTTP headers you configure. They do not
implicitly generate the custom HMAC protocol below. Do not send a project
service-role key to an arbitrary outbound URL as a generic webhook secret.
Use a receiver-specific credential or the documented intended gateway identity,
kept in an appropriate secret store, with minimal capability and rotation scope.

For the application-owned HMAC example, the sender and receiver BOTH implement
[the exact raw-byte and timestamp contract](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/signature-verification.md).
Missing receiver configuration, invalid signature, stale/future timestamp or
malformed input is rejected before inbox insertion. Timestamp freshness alone is
not durable replay prevention.

The gateway and handler must agree: a JWT-protected Edge Function needs the actual
supported gateway authentication identity; an HMAC-only endpoint requires a
consciously configured dedicated route that permits that sender and enforces HMAC
inside the handler. Do not blindly disable JWT checks on other functions or claim
that HMAC headers satisfy JWT verification. A receiver's server-only database key
is not an outbound sender credential and must never appear in delivery headers.

## Instructions

### Step 1: Select One Delivery Contract

Inventory the event source, authorized endpoint, payload fields, producer identity,
retries, timeout, dead-letter path and protected evidence. Review any trigger SQL
before applying it. A Database Webhook payload (`type`, `table`, `record`,
`old_record`) is not automatically the custom signed inbox envelope. The legacy
[Database Webhook reference](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/database-webhooks.md) describes transport
mechanics; its SQL alone does not provide this custom signature/outbox guarantee.
Do not connect an unsigned trigger to the signed receiver and weaken verification
to make it pass.

### Step 2: Authenticate and Persist an Inbox Record

Use [the bounded receiver and explicit inbox schema](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/edge-function-receivers.md)
with [the matching sender/verifier](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/signature-verification.md). The
producer supplies a unique event ID for each distinct event and retains it across
retries. The receiver authenticates raw bytes before strict JSON/schema validation,
then attempts one unique-key insert. No SELECT-then-side-effect-INSERT sequence and
no row-ID/type-derived deduplication key is used.

202 means accepted into the inbox, with `processingComplete: false`. 409 means the
ID already exists and requires producer-receipt reconciliation, not proof of
completed effects or identical payload. A lost response after commit requires
reconciliation of that SAME ID. Build a separate authorized worker with durable
lease/retry/dead-letter and effect-idempotency semantics before enabling business
actions. No executable business stub is supplied here.

### Step 3: Treat Notifications as Hints, Not Durable Work Completion

LISTEN/NOTIFY is not a persistent queue. Its payload size has a strict byte limit;
oversized payloads fail rather than being safely truncated. Send minimal IDs and
re-read authorized state. Realtime subscriptions similarly need correct user/RLS
and publication setup plus reconciliation after reconnect. Do not log changed rows
or infer guaranteed event recovery from a successful subscription.

See [notification and Realtime mechanics](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/listen-notify-realtime.md),
reviewing authentication, lifecycle cleanup and evidence boundaries for the actual
application before adopting any example.

## Output

- Explicit transport and authentication contracts, with native/custom boundaries
- Unique producer event IDs and durable accepted-inbox receipts
- Separate worker/retry/reconciliation requirements and unresolved processing state
- Operational evidence without payloads, tokens or secret headers

## Error Handling

| Observation                | Required check                                                                           |
| -------------------------- | ---------------------------------------------------------------------------------------- |
| HTTP 401/403               | Match actual gateway and handler authentication; never bypass verification to resolve it |
| Missing HMAC configuration | Fail closed; do not insert or acknowledge acceptance                                     |
| Duplicate event ID         | Reconcile durable producer/inbox receipts; do not invent a new ID for the retry          |
| Inbox error/timeout        | No completed-effects claim; reconcile possible commit before retry                       |
| Realtime silence           | Check identity, policies, publication, connectivity and reconciliation                   |
| NOTIFY oversize            | Reduce to IDs; no truncation guarantee                                                   |

## Examples

- [Signed protocol and request builder](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/signature-verification.md):
  explicit application-owned headers/raw bytes, not a native signing claim.
- [Inbox receiver](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events/references/edge-function-receivers.md): bounded validation and
  checked unique insertion, no business completion acknowledgment.

## Resources

- [Database Webhooks](https://supabase.com/docs/guides/database/webhooks)
- [pg_net](https://supabase.com/docs/guides/database/extensions/pg_net)
- [Securing Edge Functions](https://supabase.com/docs/guides/functions/auth)
- [Realtime Postgres Changes](https://supabase.com/docs/guides/realtime/postgres-changes)
- [PostgreSQL NOTIFY](https://www.postgresql.org/docs/current/sql-notify.html)

## Next Steps

Review worker authorization, durable delivery/processing receipts, replay horizons
and failure recovery before enabling side effects or claiming production readiness.
