Data Inc.

Developers / Build / Webhooks & events

Webhooks & events

Register HTTPS receivers, verify signed events and handle retries from the Hub's implemented webhook system.

Paths, headers and fields mirror The IDIA Hub's Protocol API implementation, checked November 7, 2026. Keys and credit rates are issued per organization inside the Hub; source review is not an independent production assessment.

Register and manage receivers

Webhook registration, listing, disabling and signed test delivery are implemented in the Hub. Send x-api-key. POST /v1/webhooks accepts url, events and optional credit_threshold; the response is 201 with webhook and signing_secret. Save the secret server-side: it is returned only on creation, never by listing.

Use an HTTPS URL (maximum 2,048 characters); local and selected private hosts are rejected. Maximum 10 active webhooks per account. events must contain at least one supported event. wallet.credit_depleted requires a non-negative credit_threshold.

GET /v1/webhooks returns { status: success, webhooks: [...] } for active receivers only. DELETE /v1/webhooks/{id} disables an owned active receiver and returns { status: success, deleted: <id> }; invalid IDs return 400, missing or unowned active receivers return 404 webhook_not_found.

POST /v1/webhooks/test accepts { webhook_id: <id> } or {} to test up to 10 active receivers. It returns results[] with webhook_id, delivered and response_status (null for a network failure). A 200 API response does not mean the receiving server accepted the delivery; inspect delivered.

curl -X POST https://zxyngqciipcvveigrzqt.supabase.co/functions/v1/protocol-api/v1/webhooks \
  -H "x-api-key: $IDIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://your-service.example/idia/events","events":["receipt.anchored_l2","wallet.credit_depleted"],"credit_threshold":10}'

Supported events

Events use { id, type, created_at, data }. Deduplicate by event id; the queue also deduplicates receiver/event keys. Receipt and batch events are discovered by the dispatcher in a seven-day lookback, capped at 1,000 rows per owner. This is not a complete-history guarantee.

receipt.anchored_l2 data: liability_receipt_id, status: anchored_l2, blockchain_proof: { network: base_mainnet, aca_hash }. wallet.credit_depleted data: synapse_credits_available, threshold, currency: CRD; emitted after utility billing strictly below the highest subscribed threshold, deduplicated per receiver / UTC date. It is not a generic per-operation notification.

telemetry.spatial_event data: batch_id, status: sanitized_and_anchored, records_processed, sanitized_hash, l2_anchor (null or network, transaction_hash, anchored_at, explorer_url). webhook.test data: webhook_id and message. feature.batch_ready, session.expired and stream.error are SSE events, not webhook subscriptions; no receipt.settled, credits.low_balance or liability_nft.minted webhook is established by this implementation.

EventTriggerFollow-up
receipt.anchored_l2Dispatcher finds a receipt with a recorded ACA hash in its seven-day lookbackGET /v1/utility/receipts/{id}
wallet.credit_depletedAn authorized utility charge leaves balance strictly below the highest subscribed thresholdGET /v1/billing/balance; deliveries deduplicated per receiver / UTC date
telemetry.spatial_eventDispatcher finds an anchored Vulture ledger batch in its seven-day lookbackRecorded anchored status, not independent location accuracy or chain verification
webhook.testAn explicit test requestInspect delivered and response_status

Signatures and retries

X-IDIA-Signature has t=<Unix seconds>,v1=<hex>. Compute HMAC-SHA256 over the exact timestamp + '.' + raw request body with the signing secret. Verify the raw bytes before JSON parsing; reject malformed signatures and stale timestamps before processing. Queue durably before acknowledging 2xx, deduplicate event IDs, and use constant-time comparison. HMAC authenticates delivery using the shared secret; it is not JWS or a certificate-backed data-truth guarantee. The example uses a five-minute tolerance as receiver-side policy, not a server guarantee.

The sender uses a 10-second timeout and accepts only 2xx responses. Queued events get at most five delivery attempts total, including the immediate attempt. Failed attempts 1–4 schedule gaps of 5, 30, 120 and 360 minutes; attempt 5 marks the event failed. A 900-minute entry exists in the configured gap array but is not reached by this five-attempt implementation. Worker scheduling determines actual delivery time; no delivery-time guarantee is established here. Test sends are direct and do not enter the retry queue. Make processing idempotent on event id.

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyIdiaSignature(rawBody: string, header: string, secret: string) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.trim().split("=")));
  if (!/^\d+$/.test(parts.t ?? "") || !/^[a-f0-9]{64}$/i.test(parts.v1 ?? "")) return false;
  if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false;
  const expected = createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest();
  const supplied = Buffer.from(parts.v1, "hex");
  return supplied.length === expected.length && timingSafeEqual(expected, supplied);
}
NextConsent & receipts