diff --git a/docs/data-sharing-webhooks.md b/docs/data-sharing-webhooks.md
new file mode 100644
index 00000000..aa108149
--- /dev/null
+++ b/docs/data-sharing-webhooks.md
@@ -0,0 +1,206 @@
+# Data sharing webhooks
+
+Phoenix Portal can push a user's own training data to an HTTPS endpoint the
+user controls. This page is for whoever builds the **receiver**, and for
+operators. For the rules the code must keep, see `CLAUDE.md` → "Data sharing
+(outbound webhooks)".
+
+- Available on **Flame and above**. Set up in the portal under
+ **Profile → Settings → Data Sharing**.
+- Up to **3 endpoints** per account. Each endpoint chooses which kinds of
+ data it receives.
+- Only the account owner can configure it, and an endpoint only ever receives
+ its owner's data.
+
+## Requirements for an endpoint
+
+| | |
+|---|---|
+| Scheme | `https` only, with a certificate a normal client would trust |
+| Host | A public DNS name or public IP. Private, loopback, link-local and reserved addresses are refused, when the endpoint is saved and again before every delivery |
+| Port | 443, or 1024–65535 |
+| Credentials | Not in the URL. Use the signature, or the optional custom header |
+| Redirects | Never followed. A `3xx` answer is a failed delivery |
+| Timeout | 10 seconds |
+| Success | Any `2xx` status. The response body is ignored and never stored |
+
+## The request
+
+Every delivery is a `POST` with a JSON body and these headers:
+
+| Header | Value |
+|---|---|
+| `content-type` | `application/json` |
+| `user-agent` | `PhoenixPortal-Webhooks/1.0` |
+| `webhook-id` | The delivery id. **The same on every retry** of that delivery: use it to deduplicate |
+| `webhook-timestamp` | Unix seconds when this attempt was signed |
+| `webhook-signature` | One or more space-separated `v1,` signatures |
+| *(your custom header)* | Only if you configured one, e.g. `Authorization` |
+
+Body:
+
+```json
+{
+ "type": "workout.updated",
+ "timestamp": "2026-11-06T12:00:00.000Z",
+ "data": {
+ "apiVersion": "2026-11-01",
+ "endpointId": "…",
+ "entity": "workout",
+ "id": "…",
+ "loadConvention": "per_cable_kg",
+ "record": { "id": "…", "name": "…", "started_at": "…", "total_volume": 1200 },
+ "children": {
+ "exercises": [{ "id": "…", "session_id": "…", "name": "Row", "cable_count": 2 }],
+ "sets": [{ "id": "…", "exercise_id": "…", "set_number": 1, "weight_kg": 40, "actual_reps": 8 }],
+ "rep_summaries": [{ "id": "…", "set_id": "…", "rep_number": 1 }]
+ }
+ }
+}
+```
+
+A deletion carries the id and nothing else:
+
+```json
+{
+ "type": "routine.deleted",
+ "timestamp": "2026-11-06T12:05:00.000Z",
+ "data": { "apiVersion": "2026-11-01", "endpointId": "…", "entity": "routine", "id": "…" }
+}
+```
+
+### Loads are per cable
+
+Every weight and volume is **per cable**, exactly as the phone shows it and as
+it is stored. Nothing is doubled. `exercises.cable_count` is `1`, `2` or
+`null`; `null` means the machine did not report it, so do not assume two.
+
+## Verifying a delivery
+
+Signatures follow the [Standard Webhooks](https://www.standardwebhooks.com)
+format, so an existing library will verify them. With the reference Node
+library:
+
+```js
+import { Webhook } from "standardwebhooks";
+
+const webhook = new Webhook(process.env.PHOENIX_SIGNING_SECRET); // "whsec_…"
+
+export async function handler(request) {
+ const body = await request.text(); // the raw body, before any JSON parsing
+ let event;
+ try {
+ event = webhook.verify(body, {
+ "webhook-id": request.headers.get("webhook-id"),
+ "webhook-timestamp": request.headers.get("webhook-timestamp"),
+ "webhook-signature": request.headers.get("webhook-signature"),
+ });
+ } catch {
+ return new Response("invalid signature", { status: 401 });
+ }
+ // event.type, event.data …
+ return new Response(null, { status: 204 });
+}
+```
+
+By hand:
+
+1. The signed content is `{webhook-id}.{webhook-timestamp}.{raw body}`.
+2. The key is the **base64-decoded** bytes after the `whsec_` prefix (not the
+ text of the secret).
+3. Compute HMAC-SHA256 and base64-encode it. Accept the delivery if it equals
+ the value after `v1,` in **any** entry of `webhook-signature`, compared in
+ constant time.
+4. Reject a `webhook-timestamp` more than a few minutes from your clock, to
+ stop replays.
+
+Verify against the raw bytes you received. Re-serialising the JSON first
+changes the bytes and the signature will not match.
+
+### The custom header
+
+For receivers that cannot verify a signature (some no-code tools), an endpoint
+can carry one extra header, for example `Authorization: Bearer …`. It is sent
+on every delivery and stored encrypted. It proves the caller knows the value;
+unlike the signature it does not protect the body from being altered, so
+prefer the signature where you can.
+
+### Replacing the secret
+
+"Replace secret" creates a new secret and shows it once. For the next
+**24 hours** each delivery carries two signatures, new secret first, so a
+receiver holding either secret keeps verifying. After that only the new one is
+used.
+
+## Events
+
+`.updated` is sent when an item is created or changed and carries its
+current state. `.deleted` is sent when it is removed. `ping` is the
+test delivery from the portal's "Send test" button.
+
+| Scope (chosen per endpoint) | Entity | `record` is a row of | `children` |
+|---|---|---|---|
+| Workouts | `workout` | `workout_sessions` | `exercises`, `sets`, `rep_summaries` |
+| Personal records | `personal_record` | `personal_records` | — |
+| Routines | `routine` | `routines` | `routine_exercises` |
+| Training cycles | `cycle` | `training_cycles` | `cycle_days` |
+| Goals | `goal` | `user_goals` | — |
+| Exercise progress | `exercise_progress` | `exercise_progress` | — |
+| Achievements | `badge`, `gamification_stats`, `rpg_attributes` | `earned_badges`, `gamification_stats`, `rpg_attributes` | — |
+| Imported activities | `external_activity` | `external_activities` (never Strava-sourced rows) | — |
+| Profile | `profile`, `local_profile` | `profiles`, `local_profiles` | — |
+
+Field names are the database column names, the same ones the "Download All My
+Data" export uses. The account's internal user id is not included.
+
+**Never sent this way:** raw force-curve telemetry, the Inferno biomechanics
+tables, activities imported from Strava, community content, billing data, or
+anything belonging to another user.
+
+## Delivery behaviour
+
+- **At least once.** A delivery can arrive more than once (a retry after your
+ `2xx` was lost, or "Resend all"). Deduplicate on `webhook-id`, or simply
+ upsert by `data.id`.
+- **Current state, not a change log.** The payload is built when it is sent.
+ Several quick edits to one item arrive as one delivery with the final state;
+ an item edited and then deleted arrives as a deletion.
+- **No ordering guarantee** between items. Because each delivery carries the
+ current state, applying them in any order converges.
+- **Timing.** Changes are picked up within about a minute, after a 20-second
+ settle delay.
+- **Retries.** Any answer other than `2xx`, a timeout or a connection failure
+ is retried after about 1 min, 5 min, 15 min, 1 h, 3 h, 6 h, 12 h and 24 h
+ (nine attempts over roughly two days). `429` and `503` honour `Retry-After`
+ up to one hour.
+- **Switched off automatically.** If a delivery uses up all its attempts, or
+ the endpoint answers `410 Gone`, the endpoint is switched off and the portal
+ says why. Switching it back on sends one test delivery first and only
+ succeeds if that is accepted.
+- **Paused with the plan.** If the account drops below Flame the endpoint is
+ paused and nothing is sent until the plan returns and the owner switches it
+ back on.
+- **Size.** A payload over 1 MB is not sent and is shown as "too large" in the
+ delivery log.
+- **Resend all** queues one delivery for every existing item in the endpoint's
+ selected data. Use it to load history into a new receiver.
+
+The portal keeps a 30-day delivery log per endpoint: status, attempt count,
+HTTP status and a fixed reason code. It never records your endpoint's response
+body.
+
+## Security notes for operators
+
+- The only code that fetches a user-chosen URL is
+ `supabase/functions/_shared/webhookTarget.ts`. Its header documents one
+ **residual risk that is not closed**: the runtime cannot pin a connection to
+ the address it validated, so DNS rebinding can still aim a request at an
+ internal address. It is bounded by https with certificate validation, by the
+ request carrying no Supabase credential, by redirects not being followed, and
+ by nothing of the response being kept beyond its status code.
+- Signing secrets and custom header values are encrypted with
+ `OAUTH_TOKEN_ENCRYPTION_KEY` in `webhook_endpoint_secrets`, which no browser
+ role can read. Rotating that key without re-encrypting makes every endpoint
+ fail with `internal_error` until its secret is replaced.
+- Operating steps (switching deliveries on and off, reading the queue) are in
+ `docs/runbooks/operations.md` → "Data Sharing Webhooks".
diff --git a/docs/edge-functions-security-audit.md b/docs/edge-functions-security-audit.md
index c29fe91c..e0048898 100644
--- a/docs/edge-functions-security-audit.md
+++ b/docs/edge-functions-security-audit.md
@@ -368,6 +368,29 @@ try {
---
+## Addendum: functions added after this audit
+
+> **Added 2026-11-06. Not part of the 2026-03-28 audit.** The functions below
+> did not exist when this report was written and were not reviewed by its
+> auditor. This is a pointer to where their security model is stated, not a
+> finding.
+
+#### `webhook-endpoints` and `deliver-webhooks` (data sharing)
+
+| Topic | Where it is decided |
+| --- | --- |
+| Authentication | `webhook-endpoints`: gateway JWT plus `auth.getUser()`; the user id comes only from the token. `deliver-webhooks`: `x-cron-secret` or service-role bearer, stated above its `verify_jwt = false` block in `supabase/config.toml` |
+| User isolation | Every query carries the JWT user id (`webhook-endpoints/index.ts`). Payload reads use the claimed delivery's owner id (`_shared/webhookPayload.ts`). A composite foreign key ties each delivery to its endpoint's owner (`20261106120000`) |
+| Tier | FLAME in `requireSubscription`, and again in SQL when deliveries are claimed |
+| Secrets | Generated server-side, returned once, AES-GCM at rest in a table no browser role can read (`webhook_endpoint_secrets`) |
+| Outbound requests (SSRF) | `_shared/webhookTarget.ts` is the only code that fetches a user-chosen URL. **Its header states a residual risk that is not closed:** DNS rebinding, bounded but not eliminated |
+| Rate limiting | General key, plus a tighter key for the actions that contact a user-chosen host |
+
+Tests that fail if these break are named in `CLAUDE.md` under "Data sharing
+(outbound webhooks)" and in `docs/data-sharing-webhooks.md`.
+
+---
+
## Recommendations Summary
### High Priority (Address Soon)
diff --git a/docs/runbooks/operations.md b/docs/runbooks/operations.md
index c4a3820a..76e0a11d 100644
--- a/docs/runbooks/operations.md
+++ b/docs/runbooks/operations.md
@@ -1737,6 +1737,89 @@ no reopen path, because auto-reopening would let a records edit un-achieve a
goal.
---
+## 15. Data Sharing Webhooks
+
+A Flame+ user's own data is pushed to endpoints they register (Profile >
+Settings > Data Sharing). Receiver-facing behaviour is in
+[`docs/data-sharing-webhooks.md`](../data-sharing-webhooks.md).
+
+### Switch deliveries on, and the kill switch
+
+The `deliver-webhooks` pg_cron job is **created inactive**. Activate it only
+after the `deliver-webhooks` Edge Function is deployed:
+
+```sql
+SELECT cron.alter_job(
+ (SELECT jobid FROM cron.job WHERE jobname = 'deliver-webhooks'),
+ active := true);
+```
+
+Setting `active := false` stops every delivery for every user. Changes keep
+being captured (one waiting row per item, so the queue does not grow without
+bound) and are sent when the job is switched back on. Nothing is lost by
+pausing.
+
+It uses the same Vault secret (`edge_cron_secret`) and Edge secret
+(`CRON_SECRET`) as the other cron-invoked functions; there is nothing extra to
+set.
+
+### Is it working?
+
+```sql
+-- The worker's own responses: 200 = a pass ran; 401 = the Vault secret and
+-- CRON_SECRET differ; 404 = the function is not deployed.
+SELECT id, status_code, timed_out, error_msg, created
+FROM net._http_response ORDER BY created DESC LIMIT 20;
+
+-- Queue depth and what is failing.
+SELECT status, last_error_code, count(*)
+FROM public.webhook_deliveries
+WHERE created_at > now() - interval '24 hours'
+GROUP BY 1, 2 ORDER BY 3 DESC;
+
+-- Endpoints that are not active, and why.
+SELECT status, disabled_reason, count(*)
+FROM public.webhook_endpoints GROUP BY 1, 2;
+```
+
+| `last_error_code` | Meaning |
+| --- | --- |
+| `http_error`, `timeout`, `connection_failed`, `dns_failed`, `redirect_not_followed` | The receiver's side. Retried on the backoff schedule. |
+| `target_not_allowed` | The stored URL now resolves to a private or reserved address, or is one of our own hosts. Not sent. |
+| `internal_error` | Ours: the endpoint's secret could not be read or decrypted, or a payload read failed. Check `OAUTH_TOKEN_ENCRYPTION_KEY` and the function logs (`[DELIVER_WEBHOOKS]`). |
+| `subscription_lapsed` | The owner dropped below Flame; the endpoint was paused. Expected. |
+| `superseded`, `scope_removed`, `endpoint_inactive`, `not_shareable` | Closed without sending, by design. |
+
+A row stuck in `delivering` is a worker that died mid-send; it is reclaimed
+after its 3-minute lease with no action needed.
+
+### A user reports an endpoint "switched itself off"
+
+`webhook_endpoints.disabled_reason` says why: `too_many_failures` (a delivery
+used all nine attempts), `endpoint_gone` (the receiver answered 410), or
+`subscription_lapsed`. The user switches it back on in the portal, which sends
+one test delivery first. Do not set `status = 'active'` by hand: the table
+requires `disabled_reason` to be cleared in the same statement, and skipping
+the test delivery hides the fault that switched it off.
+
+### Stop one user's sharing immediately
+
+```sql
+UPDATE public.webhook_endpoints
+SET status = 'paused', disabled_reason = 'user_paused'
+WHERE user_id = '' AND status = 'active';
+```
+
+Account deletion removes endpoints, secrets and the delivery log by cascade.
+
+### What must never be logged or pasted into a ticket
+
+An endpoint's URL path or query (it may itself be a credential), a signing
+secret, a custom header value, or a payload. The functions log ids, status
+codes and fixed reason codes only.
+
+---
+
## Related Runbooks
- [Billing Incident Response](billing-incident-response.md) -- manual fixes,
diff --git a/e2e/data-sharing.spec.ts b/e2e/data-sharing.spec.ts
new file mode 100644
index 00000000..ac81a427
--- /dev/null
+++ b/e2e/data-sharing.spec.ts
@@ -0,0 +1,100 @@
+import { expect, test } from "@playwright/test";
+import { mockAuthenticatedApp } from "./support/mockSupabase";
+
+const USER_ID = "00000000-0000-4000-8000-000000000001";
+
+function endpoint(overrides: Record = {}) {
+ return {
+ id: "endpoint-existing",
+ user_id: USER_ID,
+ label: "Home server",
+ url: "https://hooks.example.com/in",
+ scopes: ["workouts", "routines"],
+ status: "active",
+ disabled_reason: null,
+ custom_header_name: null,
+ signing_key_hint: "abcd",
+ consecutive_failures: 0,
+ last_success_at: null,
+ last_failure_at: null,
+ created_at: "2026-11-01T12:00:00.000Z",
+ updated_at: "2026-11-01T12:00:00.000Z",
+ ...overrides,
+ };
+}
+
+test.describe("Data sharing", () => {
+ test("a Flame user adds an endpoint, sees the secret once, tests it and deletes it", async ({
+ page,
+ }) => {
+ await mockAuthenticatedApp(page, { tier: "FLAME" });
+ await page.goto("/profile?tab=settings");
+
+ const section = page.getByTestId("data-sharing");
+ await expect(section.getByText(/No endpoints yet/)).toBeVisible();
+
+ await section.getByRole("button", { name: "Add endpoint" }).click();
+ const form = page.getByRole("dialog");
+ await form.getByLabel("Name", { exact: true }).fill("Home server");
+ await form.getByLabel("Endpoint URL").fill("https://hooks.example.com/in");
+ await form.getByRole("switch", { name: "Workouts" }).click();
+ await form.getByRole("button", { name: "Add endpoint" }).click();
+
+ // The secret is shown once, then cannot be found anywhere on the page.
+ const secret = page.getByTestId("signing-secret");
+ await expect(secret).toContainText("whsec_");
+ await page.getByRole("button", { name: "I have saved it" }).click();
+ await expect(secret).toHaveCount(0);
+ await expect(page.getByText(/whsec_/)).toHaveCount(0);
+
+ await expect(section.getByText("Home server")).toBeVisible();
+ await expect(section.getByText("Active", { exact: true })).toBeVisible();
+
+ await section.getByRole("button", { name: "Send test" }).click();
+ await expect(
+ section.getByText("The receiver accepted the test delivery (200)."),
+ ).toBeVisible();
+ await section.getByRole("button", { name: "Recent deliveries" }).click();
+ await expect(section.getByText("Delivered", { exact: true })).toBeVisible();
+
+ await section.getByRole("button", { name: "Delete", exact: true }).click();
+ await page
+ .getByRole("alertdialog")
+ .getByRole("button", { name: "Delete endpoint" })
+ .click();
+ await expect(section.getByText(/No endpoints yet/)).toBeVisible();
+ });
+
+ test("a user below Flame can pause and delete an endpoint but not add or edit one", async ({
+ page,
+ }) => {
+ await mockAuthenticatedApp(page, {
+ tier: "EMBER",
+ webhookEndpoints: [endpoint()],
+ });
+ await page.goto("/profile?tab=settings");
+
+ const section = page.getByTestId("data-sharing");
+ await expect(section.getByText("Home server")).toBeVisible();
+ await expect(section.getByTestId("data-sharing-upgrade")).toContainText(
+ "Data sharing is part of Flame.",
+ );
+ await expect(
+ section.getByRole("button", { name: "Add endpoint" }),
+ ).toBeDisabled();
+ await expect(
+ section.getByRole("button", { name: "Edit", exact: true }),
+ ).toBeDisabled();
+ await expect(
+ section.getByRole("button", { name: "Send test" }),
+ ).toBeDisabled();
+
+ await section.getByRole("button", { name: "Pause", exact: true }).click();
+ await expect(section.getByText("Paused", { exact: true })).toBeVisible();
+ await expect(section.getByText("You paused this endpoint.")).toBeVisible();
+ // Switching it back on needs the plan.
+ await expect(
+ section.getByRole("button", { name: "Switch on" }),
+ ).toBeDisabled();
+ });
+});
diff --git a/e2e/support/mockSupabase.ts b/e2e/support/mockSupabase.ts
index 944dc6f6..9c969c40 100644
--- a/e2e/support/mockSupabase.ts
+++ b/e2e/support/mockSupabase.ts
@@ -108,6 +108,8 @@ interface MockSupabaseOptions {
personalRecords?: Record[];
phaseStatistics?: Record[];
exerciseProgress?: Record[];
+ /** Data sharing endpoints the user already has (webhook_endpoints rows). */
+ webhookEndpoints?: Record[];
}
const MONTHLY_PRICE_IDS: Record = {
@@ -168,6 +170,8 @@ export async function installMockSupabase(
personalRecords: options.personalRecords ?? [],
phaseStatistics: options.phaseStatistics ?? [],
exerciseProgress: options.exerciseProgress ?? [],
+ webhookEndpoints: options.webhookEndpoints ?? [],
+ webhookDeliveries: [] as Record[],
onboarding: {
id: "onboarding-1",
user_id: userId,
@@ -624,6 +628,138 @@ export async function installMockSupabase(
return;
}
+ // Data sharing: the one write path for webhook endpoints. Mirrors the
+ // Edge Function's contract closely enough for the UI: the tier gate
+ // (402 below FLAME, except delete and a pause-only update), the
+ // one-time secret, and a test delivery written to the log.
+ if (functionName === "webhook-endpoints") {
+ const respond = (status: number, payload: unknown) =>
+ route.fulfill({
+ status,
+ contentType: "application/json",
+ body: JSON.stringify(payload),
+ });
+ const pauseOnly =
+ body.action === "update" &&
+ body.status === "paused" &&
+ Object.keys(body).every((key) =>
+ ["action", "endpointId", "status"].includes(key),
+ );
+ const tier = state.subscription?.tier ?? "FREE";
+ const flame = tier === "FLAME" || tier === "INFERNO";
+ if (body.action !== "delete" && !pauseOnly && !flame) {
+ await respond(402, {
+ error: "subscription_required",
+ message: "This feature requires FLAME.",
+ requiredTier: "FLAME",
+ currentTier: tier,
+ });
+ return;
+ }
+ const timestamp = new Date().toISOString();
+
+ if (body.action === "create") {
+ if (!String(body.url).startsWith("https://")) {
+ await respond(400, {
+ error: "url_not_https",
+ message: "The URL must start with https://.",
+ });
+ return;
+ }
+ const created = {
+ id: nextId("endpoint"),
+ user_id: userId,
+ label: body.label,
+ url: body.url,
+ scopes: body.scopes,
+ status: "active",
+ disabled_reason: null,
+ custom_header_name: body.customHeader?.name ?? null,
+ signing_key_hint: "e2e1",
+ consecutive_failures: 0,
+ last_success_at: null,
+ last_failure_at: null,
+ created_at: timestamp,
+ updated_at: timestamp,
+ };
+ state.webhookEndpoints.push(created);
+ await respond(201, {
+ endpoint: created,
+ signingSecret: "whsec_e2e-test-only-shown-once-1",
+ });
+ return;
+ }
+
+ const endpoint = state.webhookEndpoints.find(
+ (row) => row.id === body.endpointId,
+ );
+ if (!endpoint) {
+ await respond(404, {
+ error: "endpoint_not_found",
+ message: "Endpoint not found.",
+ });
+ return;
+ }
+ if (body.action === "delete") {
+ state.webhookEndpoints = state.webhookEndpoints.filter(
+ (row) => row.id !== body.endpointId,
+ );
+ await respond(200, { deleted: true });
+ return;
+ }
+ if (body.action === "update") {
+ if (body.label !== undefined) endpoint.label = body.label;
+ if (body.url !== undefined) endpoint.url = body.url;
+ if (body.scopes !== undefined) endpoint.scopes = body.scopes;
+ if (body.status === "paused" && endpoint.status === "active") {
+ endpoint.status = "paused";
+ endpoint.disabled_reason = "user_paused";
+ }
+ if (body.status === "active") {
+ endpoint.status = "active";
+ endpoint.disabled_reason = null;
+ }
+ endpoint.updated_at = timestamp;
+ await respond(200, { endpoint });
+ return;
+ }
+ if (body.action === "test") {
+ state.webhookDeliveries.unshift({
+ id: nextId("delivery"),
+ endpoint_id: endpoint.id,
+ user_id: userId,
+ entity: "ping",
+ entity_id: "ping",
+ event_type: "ping",
+ status: "delivered",
+ attempt_count: 1,
+ next_attempt_at: timestamp,
+ last_status_code: 200,
+ last_error_code: null,
+ duration_ms: 42,
+ created_at: timestamp,
+ finished_at: timestamp,
+ });
+ await respond(200, {
+ delivered: true,
+ statusCode: 200,
+ errorCode: null,
+ durationMs: 42,
+ });
+ return;
+ }
+ if (body.action === "rotate_secret") {
+ endpoint.signing_key_hint = "e2e2";
+ await respond(200, {
+ endpoint,
+ signingSecret: "whsec_e2e-test-only-shown-once-2",
+ });
+ return;
+ }
+ await respond(200, { enqueued: 0 });
+ return;
+ }
+
await route.fulfill({
status: 200,
contentType: "application/json",
@@ -904,6 +1040,29 @@ export async function installMockSupabase(
});
return;
}
+ case "webhook_endpoints": {
+ await route.fulfill({
+ status: 200,
+ contentType: "application/json",
+ body: JSON.stringify(state.webhookEndpoints),
+ });
+ return;
+ }
+ case "webhook_deliveries": {
+ const endpointId = url.searchParams
+ .get("endpoint_id")
+ ?.replace(/^eq\./, "");
+ await route.fulfill({
+ status: 200,
+ contentType: "application/json",
+ body: JSON.stringify(
+ state.webhookDeliveries.filter(
+ (row) => !endpointId || row.endpoint_id === endpointId,
+ ),
+ ),
+ });
+ return;
+ }
default: {
await route.fulfill({
status: 200,
diff --git a/src/app/components/PrivacyPolicy.tsx b/src/app/components/PrivacyPolicy.tsx
index cde8e7a1..27cb2bac 100644
--- a/src/app/components/PrivacyPolicy.tsx
+++ b/src/app/components/PrivacyPolicy.tsx
@@ -40,7 +40,7 @@ export function PrivacyPolicy() {
Project Phoenix - Companion App
- Effective Date: February 20, 2026
+ Effective Date: November 6, 2026
{/* Summary Box */}
@@ -251,6 +251,18 @@ export function PrivacyPolicy() {
integration at any time (Article 6(1)(a))
+
+ •
+
+
+ Data sharing endpoints (optional):
+ {" "}
+ Consent — data is sent to an endpoint only after you add it
+ and choose what to share. You may withdraw consent by
+ pausing or deleting the endpoint at any time (Article
+ 6(1)(a))
+
+
•
@@ -470,6 +482,23 @@ export function PrivacyPolicy() {
display name and workout statistics to other users. You can
control this in your profile privacy settings.
+
+
+ Data sharing you set up yourself.
+ {" "}
+ If you add a data sharing endpoint in your profile settings, we
+ send the kinds of data you select (for example workouts,
+ personal records, routines and training cycles) to the web
+ address you provide, each time that data changes. This is off
+ unless you turn it on, only you can configure it for your
+ account, and each endpoint receives only your own data. We never
+ send raw force-curve telemetry, activities imported from Strava,
+ your payment details or other users' data this way. The
+ recipient is chosen by you and does not act on our behalf: once
+ data reaches your endpoint, how it is stored and used is between
+ you and whoever operates it. You can pause or delete an endpoint
+ at any time, and sharing stops immediately.
+
@@ -574,6 +603,18 @@ export function PrivacyPolicy() {
Clauses for EEA/UK data transfers
+
+ •
+
+
+ Data sharing endpoints:
+ {" "}
+ If you set one up, the data you select is sent to wherever
+ that endpoint is hosted, which may be outside your country
+ of residence. That transfer is made at your direction, to a
+ recipient you chose
+
+
Where your data is transferred outside the European Economic
diff --git a/src/app/components/Profile.tsx b/src/app/components/Profile.tsx
index 4c448ab3..b70770be 100644
--- a/src/app/components/Profile.tsx
+++ b/src/app/components/Profile.tsx
@@ -20,6 +20,7 @@ import { Link, useSearchParams } from "react-router";
import { toast } from "sonner";
import { PageShell } from "@/app/components/PageShell";
import { DangerZone } from "@/app/components/profile/DangerZone";
+import { DataSharingSection } from "@/app/components/profile/DataSharingSection";
import { ExportSection } from "@/app/components/profile/ExportSection";
import { ProfileAvatarImage } from "@/app/components/profile/ProfileAvatarImage";
import { TierBadge } from "@/app/components/TierBadge";
@@ -1163,6 +1164,10 @@ export function Profile() {
{/* Data Export - available to all tiers (no SubscriptionGate) */}
+ {/* Data sharing: listed for every tier so a lapsed user can pause
+ or delete; adding and editing need Flame (server-enforced). */}
+
+
{/* Account Deletion - available to all tiers (GDPR right to erasure) */}
diff --git a/src/app/components/__tests__/DataSharingSection.test.tsx b/src/app/components/__tests__/DataSharingSection.test.tsx
new file mode 100644
index 00000000..025b5dd4
--- /dev/null
+++ b/src/app/components/__tests__/DataSharingSection.test.tsx
@@ -0,0 +1,383 @@
+import { fireEvent, screen, waitFor, within } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { renderWithProviders } from "@/test/test-utils";
+
+const state = vi.hoisted(() => ({
+ endpoints: [] as Record[],
+ deliveries: [] as Record[],
+ subscription: {
+ tier: "FLAME",
+ isLoading: false,
+ isError: false,
+ refetch: () => Promise.resolve(),
+ },
+ invoke: vi.fn(),
+ toast: { success: vi.fn(), error: vi.fn() },
+}));
+
+vi.mock("@/app/hooks/useAuth", () => ({
+ useAuth: () => ({ user: { id: "test-user-id" } }),
+}));
+
+vi.mock("@/hooks/useSubscription", () => ({
+ useSubscription: () => state.subscription,
+}));
+
+vi.mock("sonner", () => ({
+ toast: {
+ success: (...args: unknown[]) => state.toast.success(...args),
+ error: (...args: unknown[]) => state.toast.error(...args),
+ info: vi.fn(),
+ },
+}));
+
+// A PostgREST builder double: every filter returns the builder, and awaiting
+// it yields the rows of the table it was opened on.
+vi.mock("@/lib/supabase", () => {
+ const builder = (rows: () => unknown[]) => {
+ const chain: Record = {};
+ for (const method of ["select", "eq", "order", "limit"]) {
+ chain[method] = () => chain;
+ }
+ // biome-ignore lint/suspicious/noThenProperty: a PostgREST builder is awaited
+ chain.then = (resolve: (value: unknown) => unknown) =>
+ Promise.resolve({ data: rows(), error: null }).then(resolve);
+ return chain;
+ };
+ return {
+ supabase: {
+ from: (table: string) =>
+ builder(() =>
+ table === "webhook_endpoints" ? state.endpoints : state.deliveries,
+ ),
+ functions: {
+ invoke: (...args: unknown[]) => state.invoke(...args),
+ },
+ },
+ };
+});
+
+import { DataSharingSection } from "@/app/components/profile/DataSharingSection";
+
+// Obviously fake, and not shaped like a real secret: nothing here verifies it.
+const SECRET = "whsec_test-only-not-a-real-secret";
+
+function endpoint(overrides: Record = {}) {
+ return {
+ id: "e-1",
+ label: "Home server",
+ url: "https://hooks.example.com/in",
+ scopes: ["workouts", "routines"],
+ status: "active",
+ disabled_reason: null,
+ custom_header_name: null,
+ signing_key_hint: "LaSw",
+ consecutive_failures: 0,
+ last_success_at: null,
+ last_failure_at: null,
+ created_at: "2026-11-06T12:00:00.000Z",
+ updated_at: "2026-11-06T12:00:00.000Z",
+ ...overrides,
+ };
+}
+
+function button(name: RegExp | string) {
+ return screen.getByRole("button", { name }) as HTMLButtonElement;
+}
+
+describe("DataSharingSection", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ state.endpoints = [];
+ state.deliveries = [];
+ state.subscription = {
+ tier: "FLAME",
+ isLoading: false,
+ isError: false,
+ refetch: () => Promise.resolve(),
+ };
+ });
+
+ it("shows a Flame user their endpoint and lets them manage it", async () => {
+ state.endpoints = [endpoint({ custom_header_name: "Authorization" })];
+
+ renderWithProviders();
+
+ expect(await screen.findByText("Home server")).toBeInTheDocument();
+ expect(
+ screen.getByText("https://hooks.example.com/in"),
+ ).toBeInTheDocument();
+ expect(screen.getByText("Active")).toBeInTheDocument();
+ expect(screen.getByText("Workouts")).toBeInTheDocument();
+ expect(screen.getByText("Routines")).toBeInTheDocument();
+ expect(screen.getByText("LaSw")).toBeInTheDocument();
+ expect(screen.getByText("Authorization")).toBeInTheDocument();
+ for (const name of [
+ /add endpoint/i,
+ /send test/i,
+ /^edit$/i,
+ /replace secret/i,
+ /resend all/i,
+ /^pause$/i,
+ /^delete$/i,
+ ]) {
+ expect(button(name).disabled, String(name)).toBe(false);
+ }
+ expect(screen.queryByTestId("data-sharing-upgrade")).toBeNull();
+ });
+
+ it("lets a user below Flame pause and delete but nothing else", async () => {
+ state.subscription = { ...state.subscription, tier: "EMBER" };
+ state.endpoints = [endpoint()];
+
+ renderWithProviders();
+
+ await screen.findByText("Home server");
+ expect(screen.getByTestId("data-sharing-upgrade")).toHaveTextContent(
+ /part of Flame/,
+ );
+ expect(screen.getByTestId("data-sharing-upgrade")).toHaveTextContent(
+ /pause or delete/,
+ );
+ expect(button(/^pause$/i).disabled).toBe(false);
+ expect(button(/^delete$/i).disabled).toBe(false);
+ for (const name of [
+ /add endpoint/i,
+ /send test/i,
+ /^edit$/i,
+ /replace secret/i,
+ /resend all/i,
+ ]) {
+ expect(button(name).disabled, String(name)).toBe(true);
+ }
+ });
+
+ it("does not tell a paying user to upgrade when billing is unavailable", async () => {
+ state.subscription = { ...state.subscription, tier: "FREE", isError: true };
+ state.endpoints = [endpoint()];
+
+ renderWithProviders();
+
+ await screen.findByText("Home server");
+ expect(screen.queryByTestId("data-sharing-upgrade")).toBeNull();
+ expect(
+ screen.getByText(/billing status is unavailable/i),
+ ).toBeInTheDocument();
+ expect(button(/add endpoint/i).disabled).toBe(true);
+ expect(button(/^pause$/i).disabled).toBe(false);
+ });
+
+ it("says why an endpoint was switched off and offers to switch it back on", async () => {
+ state.endpoints = [
+ endpoint({
+ status: "disabled",
+ disabled_reason: "too_many_failures",
+ consecutive_failures: 9,
+ }),
+ ];
+
+ renderWithProviders();
+
+ expect(await screen.findByText("Switched off")).toBeInTheDocument();
+ expect(
+ screen.getByText(/switched off after repeated failed deliveries/i),
+ ).toBeInTheDocument();
+ expect(button(/switch on/i).disabled).toBe(false);
+ // Nothing to resend to while it is off.
+ expect(button(/resend all/i).disabled).toBe(true);
+ });
+
+ it("stops offering a new endpoint at the limit", async () => {
+ state.endpoints = [
+ endpoint({ id: "e-1" }),
+ endpoint({ id: "e-2", label: "Second" }),
+ endpoint({ id: "e-3", label: "Third" }),
+ ];
+
+ renderWithProviders();
+
+ await screen.findByText("Third");
+ expect(button(/add endpoint/i).disabled).toBe(true);
+ expect(screen.getByText(/maximum of 3 endpoints/i)).toBeInTheDocument();
+ });
+
+ it("creates an endpoint from the form and shows the secret once", async () => {
+ state.invoke.mockResolvedValue({
+ data: { endpoint: endpoint(), signingSecret: SECRET },
+ error: null,
+ });
+ renderWithProviders();
+ await screen.findByText(/no endpoints yet/i);
+
+ // Act: fill in the form and submit.
+ fireEvent.click(button(/add endpoint/i));
+ const dialog = await screen.findByRole("dialog");
+ fireEvent.change(within(dialog).getByLabelText("Name"), {
+ target: { value: "Home server" },
+ });
+ fireEvent.change(within(dialog).getByLabelText("Endpoint URL"), {
+ target: { value: "https://hooks.example.com/in" },
+ });
+ fireEvent.click(within(dialog).getByRole("switch", { name: "Workouts" }));
+ fireEvent.click(
+ within(dialog).getByRole("button", { name: "Add endpoint" }),
+ );
+
+ // Assert: one create call, with no user id for the server to trust.
+ await waitFor(() => expect(state.invoke).toHaveBeenCalledTimes(1));
+ expect(state.invoke).toHaveBeenCalledWith("webhook-endpoints", {
+ body: {
+ action: "create",
+ label: "Home server",
+ url: "https://hooks.example.com/in",
+ scopes: ["workouts"],
+ },
+ });
+ // The secret is shown...
+ expect(await screen.findByTestId("signing-secret")).toHaveTextContent(
+ SECRET,
+ );
+ // ...and gone for good once the dialog is closed.
+ fireEvent.click(button(/i have saved it/i));
+ await waitFor(() =>
+ expect(screen.queryByTestId("signing-secret")).toBeNull(),
+ );
+ expect(document.body.textContent).not.toContain(SECRET);
+ });
+
+ it("does not call the server while the form is invalid", async () => {
+ renderWithProviders();
+ await screen.findByText(/no endpoints yet/i);
+
+ fireEvent.click(button(/add endpoint/i));
+ const dialog = await screen.findByRole("dialog");
+ fireEvent.change(within(dialog).getByLabelText("Name"), {
+ target: { value: "Home server" },
+ });
+ fireEvent.change(within(dialog).getByLabelText("Endpoint URL"), {
+ target: { value: "http://hooks.example.com/in" },
+ });
+ fireEvent.click(
+ within(dialog).getByRole("button", { name: "Add endpoint" }),
+ );
+
+ expect(
+ await within(dialog).findByText("The URL must start with https://."),
+ ).toBeInTheDocument();
+ expect(
+ within(dialog).getByText("Choose at least one kind of data to share."),
+ ).toBeInTheDocument();
+ expect(state.invoke).not.toHaveBeenCalled();
+ });
+
+ it("pauses an endpoint with a pause-only request", async () => {
+ state.endpoints = [endpoint()];
+ state.invoke.mockResolvedValue({
+ data: {
+ endpoint: endpoint({
+ status: "paused",
+ disabled_reason: "user_paused",
+ }),
+ },
+ error: null,
+ });
+ renderWithProviders();
+ await screen.findByText("Home server");
+
+ fireEvent.click(button(/^pause$/i));
+
+ // Exactly these keys: the server lets a pause through without Flame
+ // only when nothing else rides along.
+ await waitFor(() =>
+ expect(state.invoke).toHaveBeenCalledWith("webhook-endpoints", {
+ body: { action: "update", endpointId: "e-1", status: "paused" },
+ }),
+ );
+ });
+
+ it("shows the result of a test delivery", async () => {
+ state.endpoints = [endpoint()];
+ state.invoke.mockResolvedValue({
+ data: {
+ delivered: false,
+ statusCode: 503,
+ errorCode: "http_error",
+ durationMs: 120,
+ },
+ error: null,
+ });
+ renderWithProviders();
+ await screen.findByText("Home server");
+
+ fireEvent.click(button(/send test/i));
+
+ expect(
+ await screen.findByText(
+ "The receiver answered with an error status (503).",
+ ),
+ ).toBeInTheDocument();
+ expect(state.invoke).toHaveBeenCalledWith("webhook-endpoints", {
+ body: { action: "test", endpointId: "e-1" },
+ });
+ });
+
+ it("asks before deleting and only then calls the server", async () => {
+ state.endpoints = [endpoint()];
+ state.invoke.mockResolvedValue({ data: { deleted: true }, error: null });
+ renderWithProviders();
+ await screen.findByText("Home server");
+
+ fireEvent.click(button(/^delete$/i));
+ const confirm = await screen.findByRole("alertdialog");
+ expect(state.invoke).not.toHaveBeenCalled();
+ fireEvent.click(
+ within(confirm).getByRole("button", { name: "Delete endpoint" }),
+ );
+
+ await waitFor(() =>
+ expect(state.invoke).toHaveBeenCalledWith("webhook-endpoints", {
+ body: { action: "delete", endpointId: "e-1" },
+ }),
+ );
+ });
+
+ it("surfaces the server's reason when a save is refused", async () => {
+ const { FunctionsHttpError } = await import("@supabase/supabase-js");
+ state.invoke.mockResolvedValue({
+ data: null,
+ error: new FunctionsHttpError(
+ new Response(
+ JSON.stringify({
+ error: "url_resolves_to_private_address",
+ message: "That host resolves to a private or reserved address.",
+ }),
+ { status: 400 },
+ ),
+ ),
+ });
+ renderWithProviders();
+ await screen.findByText(/no endpoints yet/i);
+
+ fireEvent.click(button(/add endpoint/i));
+ const dialog = await screen.findByRole("dialog");
+ fireEvent.change(within(dialog).getByLabelText("Name"), {
+ target: { value: "Internal" },
+ });
+ fireEvent.change(within(dialog).getByLabelText("Endpoint URL"), {
+ target: { value: "https://internal.example.com/in" },
+ });
+ fireEvent.click(within(dialog).getByRole("switch", { name: "Workouts" }));
+ fireEvent.click(
+ within(dialog).getByRole("button", { name: "Add endpoint" }),
+ );
+
+ await waitFor(() =>
+ expect(state.toast.error).toHaveBeenCalledWith(
+ "That host resolves to a private or reserved address.",
+ ),
+ );
+ // The form stays open so the URL can be corrected.
+ expect(screen.getByRole("dialog")).toBeInTheDocument();
+ expect(screen.queryByTestId("signing-secret")).toBeNull();
+ });
+});
diff --git a/src/app/components/profile/DataSharingSection.tsx b/src/app/components/profile/DataSharingSection.tsx
new file mode 100644
index 00000000..19148028
--- /dev/null
+++ b/src/app/components/profile/DataSharingSection.tsx
@@ -0,0 +1,229 @@
+import { useQuery } from "@tanstack/react-query";
+import { Plus, Share2 } from "lucide-react";
+import { useState } from "react";
+import { Link } from "react-router";
+import { toast } from "sonner";
+import { EndpointCard } from "@/app/components/profile/data-sharing/EndpointCard";
+import {
+ EndpointFormDialog,
+ type EndpointFormSubmission,
+} from "@/app/components/profile/data-sharing/EndpointFormDialog";
+import {
+ type RevealedSecret,
+ SecretRevealDialog,
+} from "@/app/components/profile/data-sharing/SecretRevealDialog";
+import { Button } from "@/app/components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+} from "@/app/components/ui/card";
+import { Skeleton } from "@/app/components/ui/skeleton";
+import { useAuth } from "@/app/hooks/useAuth";
+import { useSubscription } from "@/hooks/useSubscription";
+import { MAX_WEBHOOK_ENDPOINTS, type WebhookEndpoint } from "@/lib/dataSharing";
+import { TIER_LEVEL } from "@/lib/subscription-entitlement";
+import { FEATURE_MIN_TIER } from "@/lib/tierMatrix";
+import {
+ useCreateWebhookEndpoint,
+ useUpdateWebhookEndpoint,
+} from "@/mutations/dataSharing";
+import { webhookEndpointsOptions } from "@/queries/dataSharing";
+
+type FormState = { endpoint: WebhookEndpoint | null } | null;
+
+/**
+ * Profile > Settings > Data Sharing. Lives on a route with no tier gate on
+ * purpose: someone whose plan lapsed must still be able to see where their
+ * data was going and pause or delete it. Adding, editing and switching an
+ * endpoint on need Flame, here for the buttons and on the server for real.
+ */
+export function DataSharingSection() {
+ const { user } = useAuth();
+ const userId = user?.id ?? "";
+ const subscription = useSubscription();
+ const {
+ data: endpoints,
+ isLoading,
+ isError,
+ refetch,
+ } = useQuery(webhookEndpointsOptions(userId));
+
+ const [form, setForm] = useState(null);
+ const [revealed, setRevealed] = useState(null);
+ const create = useCreateWebhookEndpoint(userId);
+ const update = useUpdateWebhookEndpoint(userId);
+
+ // A billing outage is not "no plan": it disables changes without telling a
+ // paying user to upgrade.
+ const billingUnavailable = subscription.isError;
+ const tierKnown = !subscription.isLoading && !billingUnavailable;
+ const canManage =
+ tierKnown &&
+ TIER_LEVEL[subscription.tier] >= TIER_LEVEL[FEATURE_MIN_TIER.dataSharing];
+ const needsUpgrade = tierKnown && !canManage;
+ const count = endpoints?.length ?? 0;
+ const atLimit = count >= MAX_WEBHOOK_ENDPOINTS;
+
+ const handleSubmit = (values: EndpointFormSubmission) => {
+ const editing = form?.endpoint ?? null;
+ if (!editing) {
+ create.mutate(
+ {
+ label: values.label,
+ url: values.url,
+ scopes: values.scopes,
+ ...(values.customHeader ? { customHeader: values.customHeader } : {}),
+ },
+ {
+ onSuccess: (result) => {
+ setForm(null);
+ setRevealed({
+ endpointLabel: result.endpoint.label,
+ signingSecret: result.signingSecret,
+ rotated: false,
+ });
+ },
+ },
+ );
+ return;
+ }
+ update.mutate(
+ {
+ endpointId: editing.id,
+ label: values.label,
+ scopes: values.scopes,
+ // Only when it changed: a new URL is re-validated and resolved.
+ ...(values.url !== editing.url ? { url: values.url } : {}),
+ ...(values.customHeader !== undefined
+ ? { customHeader: values.customHeader }
+ : {}),
+ },
+ {
+ onSuccess: () => {
+ setForm(null);
+ toast.success("Endpoint updated");
+ },
+ },
+ );
+ };
+
+ return (
+
+
+
+
+ Data Sharing
+
+
+ Send your own training data to an HTTPS endpoint you control, as
+ signed webhook events. Only you can set this up, and each endpoint
+ receives only your data.
+
+
+
+ {needsUpgrade && (
+
+ Data sharing is part of Flame.{" "}
+
+ See plans
+
+ {count > 0
+ ? " Your endpoints are listed below so you can pause or delete them; nothing is sent while your plan does not include data sharing."
+ : ""}
+
+ )}
+ {billingUnavailable && (
+
+ Billing status is unavailable, so changes are switched off for the
+ moment. You can still pause or delete an endpoint.{" "}
+
+
+ )}
+
+ {isLoading ? (
+
+ ) : isError ? (
+
+
+ Couldn't load your endpoints.
+
+
+
+ ) : count === 0 ? (
+
+ No endpoints yet. Add one to start receiving your workouts, records,
+ routines and more as they change.
+
+ {atLimit
+ ? `You have the maximum of ${MAX_WEBHOOK_ENDPOINTS} endpoints.`
+ : `Up to ${MAX_WEBHOOK_ENDPOINTS} endpoints.`}
+
+
+
+
+ Loads are sent per cable, as on the phone. Raw force-curve telemetry,
+ advanced biomechanics data and activities imported from Strava are
+ never shared this way. The complete download above is unaffected.
+
+
+
+ setForm(null)}
+ />
+ setRevealed(null)} />
+
+ );
+}
diff --git a/src/app/components/profile/data-sharing/DeliveryLog.tsx b/src/app/components/profile/data-sharing/DeliveryLog.tsx
new file mode 100644
index 00000000..2172c129
--- /dev/null
+++ b/src/app/components/profile/data-sharing/DeliveryLog.tsx
@@ -0,0 +1,119 @@
+import { useQuery } from "@tanstack/react-query";
+import { formatRelative } from "@/app/components/integrations/formatRelative";
+import { Badge } from "@/app/components/ui/badge";
+import { Skeleton } from "@/app/components/ui/skeleton";
+import { describeDeliveryError } from "@/lib/dataSharing";
+import {
+ WEBHOOK_DELIVERY_LOG_LIMIT,
+ type WebhookDelivery,
+ webhookDeliveriesOptions,
+} from "@/queries/dataSharing";
+
+const STATUS_LABEL: Record = {
+ pending: "Waiting",
+ delivering: "Sending",
+ delivered: "Delivered",
+ dead: "Failed",
+ skipped: "Not sent",
+};
+
+const STATUS_CLASS: Record = {
+ pending: "bg-secondary/40 text-foreground",
+ delivering: "bg-secondary/40 text-foreground",
+ delivered: "bg-success/20 text-success",
+ dead: "bg-destructive/20 text-destructive",
+ skipped: "bg-muted/30 text-muted-foreground",
+};
+
+/** What a delivery was about: the resolved event, or the item while it waits. */
+function deliverySubject(delivery: WebhookDelivery): string {
+ return delivery.event_type ?? delivery.entity.replaceAll("_", " ");
+}
+
+function deliveryDetail(delivery: WebhookDelivery): string | null {
+ if (delivery.status === "pending" && delivery.attempt_count > 0) {
+ // A retry is scheduled: say what went wrong last time and when it retries.
+ const reason = describeDeliveryError(
+ delivery.last_error_code,
+ delivery.last_status_code,
+ );
+ const when = new Date(delivery.next_attempt_at).toLocaleString();
+ return `${reason ?? "Last attempt failed"}. Retrying at ${when}.`;
+ }
+ if (delivery.status === "delivered") {
+ return delivery.duration_ms === null
+ ? null
+ : `${delivery.last_status_code ?? ""} in ${delivery.duration_ms} ms`.trim();
+ }
+ return describeDeliveryError(
+ delivery.last_error_code,
+ delivery.last_status_code,
+ );
+}
+
+interface DeliveryLogProps {
+ userId: string;
+ endpointId: string;
+}
+
+/** The endpoint's latest deliveries, read directly under owner RLS. */
+export function DeliveryLog({ userId, endpointId }: DeliveryLogProps) {
+ const { data, isLoading, isError } = useQuery(
+ webhookDeliveriesOptions(userId, endpointId),
+ );
+
+ if (isLoading) return ;
+ if (isError) {
+ return (
+
+ Couldn't load the delivery log. Try again in a moment.
+
+ );
+ }
+ if (!data?.length) {
+ return (
+
+ No deliveries yet. They appear here within a minute or two of a change.
+