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.

Persist a vault

By default, vaults expire after their TTL (24 hours on Hobby, 7 days on Pro). Persisting a vault pauses the TTL countdown and keeps the vault accessible until you explicitly delete it or your persisted vault quota is reached.

When to persist

  • The caller needs to download results after the TTL expires
  • You want to archive payment results for compliance
  • A long-running job produces results that should outlive the default TTL

Persist a vault

import { initialise } from '@prudra/core';
import { persistVault } from '@prudra/vault';

initialise({ apiKey: process.env.PRUDRA_API_KEY! });

await persistVault({ vaultId: 'vlt_clx1abc123' });

Persist from within your handler

Persist during the request if you know in advance the vault should survive:
app.post('/generate', walletMiddleware(...), payMiddleware(...), vaultMiddleware(), async (req, res) => {
  const vault = req.vault!;

  const report = await generateReport();
  await vault.addDocument(report, 'Report');
  await vault.seal('Report generated');

  // Persist so caller can download even if they return hours later
  await vault.persist();

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

Persisted vault quota

Persisting consumes your persisted vault quota — separate from active vault quota:
PlanPersisted vaults
Hobby1
Pro20
EnterpriseUnlimited
When the quota is full, persistVault() returns a persisted-vault-quota-exceeded error. Delete older persisted vaults to free quota.

Extending TTL without persisting

If you want to extend the TTL without permanently persisting, use extendVaultTtl():
import { extendVaultTtl } from '@prudra/vault';

await extendVaultTtl({
  vaultId:  'vlt_clx1abc123',
  ttlHours: 48,  // new TTL from now
});
This pushes the expiry forward without consuming persisted vault quota.

Error handling

ErrorStatusCauseResolution
persisted-vault-quota-exceeded429Persisted vault limit reachedDelete old persisted vaults
vault-already-persisted409Already persistedNo action needed
vault-expired404Vault already expiredCannot persist expired vaults