TinyCloud write hooks let you react to changes inDocumentation Index
Fetch the complete documentation index at: https://docs.tinycloud.xyz/llms.txt
Use this file to discover all available pages before exploring further.
kv, sql, and duckdb without polling. The same tc.hooks surface supports two delivery modes:
- SSE subscriptions for live, in-process consumers
- Durable webhooks for external systems that need POST delivery and retries
| Field | Meaning |
|---|---|
space | The TinyCloud space to observe |
service | One of kv, sql, or duckdb |
pathPrefix | Optional path filter within that service |
abilities | Optional ability filter. Supported values are tinycloud.kv/put, tinycloud.kv/del, tinycloud.sql/write, and tinycloud.duckdb/write |
pathPrefix matches the exact path or anything below it. For example, documents matches documents and documents/notes.
Supported Services
Write hooks are available for:kvsqlduckdb
sql and duckdb, hook paths use the database/table form:
kv, the path is the key that was written or deleted.
Live SSE Subscriptions
Usetc.hooks.subscribe() when your app can stay connected to TinyCloud and process events directly. The SDK multiplexes logical subscriptions onto one physical stream per host and invoker.
- Node SDK
- Web SDK
subscribe() returns an async iterable of raw type: "write" events. Each event is emitted after the write succeeds and is filtered by the scope you requested.
The stream is live-only: there is no replay cursor, backfill, or missed-event recovery on reconnect.
Durable Webhooks
Usetc.hooks.register() when the receiver lives outside the current process and needs HTTP POST delivery.
- Register
- List and unregister
active flag, and creation time. The secret is stored encrypted on the server; keep the plaintext secret only in your own deployment or secret manager.
The secret field is required. TinyCloud signs each delivery with X-TinyCloud-Signature: sha256=<hex hmac> over the raw request body.
Event Shape
Write events follow the same raw payload shape across SSE and webhooks:path is the key for KV events and <db>/<table> for SQL and DuckDB events.
Webhook deliveries use the same event payload as the HTTP body and are signed with X-TinyCloud-Signature: sha256=<hex hmac>.
Delivery Semantics
SSE is live-only. There is no replay cursor or backfill, and if a client falls behind or reconnects after a gap, missed events are not recovered. Webhooks are durable and at-least-once. Duplicate deliveries are possible, so receivers must be idempotent. For KV webhooks, durable enqueue happens from the KV commit path. For SQL and DuckDB webhooks, durable enqueue happens after the write succeeds, so the delivery record is not in the same atomic transaction as the data write. That weaker atomicity is intentional and matches the shipped implementation.Self-Hosting Notes
If you self-host TinyCloud, hook-related limits live under the[hooks] config section:
TINYCLOUD_ environment variables such as TINYCLOUD_HOOKS__MAX_TICKET_TTL_SECONDS=300 and TINYCLOUD_STORAGE__DATABASE="postgres://user:pass@localhost:5432/tinycloud".
When To Use Which
- Use SSE when your consumer is already inside your app or worker process.
- Use webhooks when you need external delivery, retry handling, or decoupled processing.
- Use
kvfor key-level change notifications, andsqlorduckdbwhen you need table-level write hooks.