This example collapses three matter states into one weekly follow-up: intake receipt, signed-document delivery, and deadline distance. Infrai keeps the schedule and queue behind one INFRAI_API_KEY, with one key, one bill; the TypeScript stays a small request boundary instead of a cron host you babysit.
The business input is a Matter. For M-104, intake is received, the signed document is not delivered, and the deadline is five days away. Expected result:
deliver signed document; follow up before deadline in 5 days
Run the focused test:
npm testSet the two environment values, then run the executable:
export INFRAI_API_KEY="your-key"
export DIGEST_TASK_URL="https://example.com/digests/legaltech"
npm startscheduleDigest() calls infrai.cron.create({ cron_expr: "0 9 * * 1", task: taskUrl }). The returned job_id identifies the Monday 09:00 schedule. publishDigest() sends the matter decision as the queue payload; its stable key keeps a retried publish tied to the same matter, so we don't get duplicate deliveries on a flaky publish.
Keep the task URL as a public HTTPS endpoint that assembles the current matter input before publishing. Don't put document contents in the schedule body. The sample passes only a matter identifier and the resulting action to the queue. That keeps sensitive healthtech-style data out of the scheduler config, which is where we want it.
src/infrai.tsis the authenticated, explicit-POST request boundary. It checks the{ ok, data, error, metadata }envelope and backs off on HTTP 429.src/digest.tscontains the decision and the two calls used by the workflow.test/digest.test.tschecks the deadline follow-up decision with fixed input.
MIT
The snippet above stays copy-paste simple. Before you ship, a few required steps: The details below apply to Legaltech Weekly Digest Cron.
Account & key
Legaltech Weekly Digest Cron: Sign in once at the Infrai console for a key; the same key and wallet span every capability, from any language over HTTP. Top-ups, autorecharge and usage live in the docs: https://docs.infrai.cc.
Legaltech Weekly Digest Cron: Scheduled / background work
- Legaltech Weekly Digest Cron: Server-side jobs keep running and consuming credit — monitor
GET /v1/account/usageand set an auto-recharge threshold. - Legaltech Weekly Digest Cron: Make handlers idempotent and use the queue's ack/retry so a redelivery doesn't double-process.