Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.prudra.dev/llms.txt

Use this file to discover all available pages before exploring further.

Events overview

Every vault has an event stream. Your server emits events using vault.emit() as work progresses, and clients subscribe to the stream using Server-Sent Events (SSE). Events are fired in real time — no polling required.

How vault events work

Clients subscribe directly to Prudra’s SSE endpoint — your server doesn’t need to manage WebSocket connections or streaming infrastructure.

Quick example

// Server: emit events during a long job
app.post('/process', walletMiddleware(...), payMiddleware(...), vaultMiddleware(), async (req, res) => {
  const vault = req.vault!;

  res.json({ vaultId: vault.id });

  setImmediate(async () => {
    await vault.emit('job.started', { itemCount: 10 });

    for (let i = 0; i < 10; i++) {
      await doWork(i);
      await vault.emit('job.progress', { current: i + 1, total: 10 });
    }

    await vault.seal('All items processed');
  });
});
# Client: subscribe to the event stream
curl -N -H "Authorization: Bearer vat_..." \
  "https://api.prudra.dev/vaults/vlt_clx1abc123/events"

# Output:
# data: {"type":"job.started","payload":{"itemCount":10}}
# data: {"type":"job.progress","payload":{"current":1,"total":10}}
# ...
# data: {"type":"vault.sealed","payload":{"summary":"All items processed"}}

Event types

TypeWhen firedFired by
Custom (any string)When your server calls vault.emit()Your server
vault.sealedWhen vault.seal() is calledPrudra
vault.expiring1 hour before TTL expiresPrudra

Sub-pages

Emit events

Emit custom events from your server handler.

Subscribe via SSE

Subscribe to the event stream from a client.

Event reference

System event payloads and custom event format.