Recipe: an agent that sleeps until it is needed
1
Create a sandbox that pauses when idle
Create the sandbox with
autoPause and a short timeout: it pauses on its own when idle, and a paused sandbox costs disk
only.2
Add a schedule for periodic work
For example every 15 minutes:
3
Add a webhook for messages from outside
A chat bot, a CI system or your own backend:The answer carries the trigger’s
url and its secret (shown this once). A sender posts to the URL with the secret in
the X-Wake-Token header.4
Let it sleep
Each firing wakes the sandbox, writes the event as a file into
/home/user/inbox, keeps the sandbox awake 30 seconds so
your agent can act on it, and the sandbox pauses again. Your agent reads the folder when it starts or wakes, so it needs no
scheduler, no queue and no process that stays up between events.Trigger types
A trigger belongs to one sandbox and is one of two types:
Each firing is an event. We store it before we answer the sender, wake the sandbox if it sleeps, and hand the event over.
Choose how an event reaches the sandbox
You pick onedeliver mode per trigger:
After a delivery the sandbox stays awake at least
keep_awake_seconds (default 60, at most 3600), then sleeps again by its
own timeout and pause settings. Create the sandbox with autoPause so its timeout pauses it instead of ending it.
The envelope:
body is the sender’s body as JSON when it is JSON, as a string when it is text, else null with body_base64. A schedule
event has "source": "schedule", scheduled_for and no body.
Set a schedule
catch_up decides: one (default) fires once for everything
missed, with "late": true; skip fires nothing for the missed slots. Either way the next slot is the next one in the future.
Verify webhook signatures
The trigger’swebhook.verify names how a request proves it comes from your sender:
The secret is shown once, when you create the trigger. A request that fails the check gets
401 and is not stored.
Rely on delivery guarantees
- Accepted means kept. A webhook gets
200 {"ok": true, "event_id": ...}only after the event is written and on disk. The sender never waits for the wake. - At least once. If we crash after your sandbox took an event and before we recorded it, you get it again with the
same
id. Use the id to drop repeats. - Retries. An event that is not taken (the port is not listening, the command exits non-zero, the wake fails) is tried again after 1, 2, 5, 10, 30, 60, 120, 300, 600, 1800 seconds, then hourly, until it is 24 hours old. Then it is dead: it stays in the event list with its last error for 7 days, and you can send it again.
- Sender retries count once. When the sender gives its own delivery id (Telegram
update_id, GitHubX-GitHub-Delivery, Stripe event id, Standard Webhookswebhook-id, or yourIdempotency-Keyheader), a retry of the same message is the same event. - Order. Events of one sandbox are handed over one at a time, oldest first. A retried event can come after a newer one.
Example: a Telegram bot that sleeps
The bot runs a small web server inside the sandbox. Telegram posts each update to the trigger’s URL; the sandbox wakes, the update is posted to the bot’s port, and the bot answers through the Bot API.1
Create a sandbox and start the bot
Create a sandbox that pauses when idle, and start the bot’s server in it (any framework that accepts webhook updates; the
update arrives as Telegram sent it):The bot itself is any server that takes the update and answers through the Bot API, for example:
2
Give it a Telegram trigger
{"id": "trg_...", "webhook": {"verify": "telegram", "url": "https://.../hooks/trg_...", "secret": "..."}, ...}3
Point the bot at it
Pass the secret as
secret_token:4
Let the sandbox sleep
Each message to the bot wakes it, is handed to
/telegram, and the sandbox sleeps again 60 seconds
later. Telegram gets its 200 before the wake, so it never times out or resends because of a slow wake.Watch and replay events
Read a trigger’s events withGET /sandboxes/{id}/triggers/{trigger}/events?status=dead&limit=100&body=true. retry sends a dead event again; fire runs the trigger now with the request body, for testing.
Each event shows status (pending, delivering, delivered, dead), attempts, last_error, received_at,
delivered_at, receive_to_deliver_ms and, when the delivery woke the sandbox, wake_ms.
Limits
A suspended account’s triggers are switched off and never wake a sandbox. While an account cannot pay, its events wait and
are tried again after a top-up. Deleting a sandbox deletes its triggers. Deleting the account removes all of its triggers
before its sandboxes are ended, and an event of a deleted account is never handed over. A wake by a trigger is billed like any other
resume.