Skip to main content
Use write hooks when you need to react to TinyCloud writes without polling. The SDK exposes the same hook scope model for live SSE subscriptions and durable webhooks.

Choose a delivery mode

  • use SSE when the consumer stays connected inside your app or worker
  • use webhooks when you need HTTP POST delivery, retries, or decoupled work
Both modes scope to:
  • space
  • service
  • optional pathPrefix
  • optional abilities

Subscribe to live writes

subscribe() is live-only. It does not replay missed events after reconnect.

Register a webhook

The webhook secret is stored encrypted on the server. TinyCloud signs each delivery with X-TinyCloud-Signature.

Verify deliveries before parsing them

The signature is sha256=<hex HMAC> over the exact request-body bytes. Capture the raw body and compare the HMAC in constant time before accepting the event. For example, with Express:
Do not run JSON middleware before this route: re-serializing parsed JSON changes the signed bytes. Keep the webhook secret in a secret manager and rotate it by re-registering the hook. Each POST body is one write event: Use X-TinyCloud-Delivery-Id as an idempotency key for delivery attempts and X-TinyCloud-Event-Id for the underlying event.

Inspect and remove hooks

Delivery semantics

  • SSE is best-effort live delivery only
  • webhooks are durable and at-least-once
  • duplicates are possible for webhooks, so receivers must be idempotent
The node normalizes pathPrefix by trimming surrounding slashes and matches the exact path or descendants beneath it.

Verification note

Verified against the TinyCloud SDK hook types and the node webhook dispatcher.