Skip to content
docs
type to search↑↓ move↵ openesc close
v0.3.2github

Receive sandbox events by webhook

3 min readv0.3.2this page as markdown
let your agent do it
Register my HTTPS receiver for Hermitbox sandbox lifecycle events.
Paste it into your agent. It follows this page as Markdown: webhooks.md

Hermitbox can send a signed HTTPS request to your endpoint when a sandbox is created, wakes, goes to sleep, fails or is deleted. Register your endpoint once, and save its signing secret to a private file: Hermitbox shows the secret only at registration.

  1. Have your HTTPS receiver ready, and pick a new file in an existing private directory for its signing secret.
  2. Set HERMITBOX_API_URL, HERMITBOX_API_KEY, HERMITBOX_WEBHOOK_URL and HERMITBOX_WEBHOOK_FILE privately, and install hermitbox in the Node program that registers the receiver.
  3. Run this once.
typescript
import { writeFileSync } from 'node:fs'
import { Hermitbox } from 'hermitbox'

// The receiver and the secret's file come from the environment.
const receiver = process.env.HERMITBOX_WEBHOOK_URL
const file = process.env.HERMITBOX_WEBHOOK_FILE
if (!receiver || !file) {
  throw new Error('Set HERMITBOX_WEBHOOK_URL and HERMITBOX_WEBHOOK_FILE')
}

// Connect with HERMITBOX_API_URL and HERMITBOX_API_KEY from the environment.
const hb = new Hermitbox()

// Register the receiver for sandbox creation and deletion.
const hook = await hb.webhook({ url: receiver, kinds: ['created', 'deleted'] })

try {
  // Save the signing secret once, to a new private file.
  const saved = JSON.stringify({ id: hook.id, secret: hook.secret }) + '\n'
  writeFileSync(file, saved, { mode: 0o600, flag: 'wx' })
} catch (error) {
  // Without the saved secret the registration is useless, so remove it.
  await hook.delete()
  throw error
}

console.log('Webhook registered')

The block never prints the secret, and it won’t overwrite an existing file. If it can’t save the secret, it removes the registration.

From a terminal, hermitbox webhook create <url> --kinds created,deleted registers the same way and prints the secret once; webhook ls, webhook rm and webhook deadletters manage registrations (CLI).

What your receiver gets

  • Kinds: created, running, sleeping, woken, resting, deleted, failed, ttl_expired and idle_slept. Register only the ones you need.
  • Payload: {id, event, sandboxId, at}. It never carries the sandbox’s environment, metadata or secret values.
  • Signature: verify hermitbox-signature (v1= and a lowercase hex HMAC-SHA256 with the saved secret) over hermitbox-timestamp, a dot and the exact received bytes. Compare in constant time, reject stale timestamps and deduplicate hermitbox-id across retries.
  • Deadline and retries: each attempt has ten seconds. Return 2xx once you have durably accepted the event; otherwise it is retried after one, two, four and eight minutes, five attempts in all, then kept as a dead letter (hermitbox webhook deadletters <webhook-id>).

Lifecycle webhooks has the full receiver contract. Events reflect the lifecycle limits of the sandbox’s tier.

Private receivers

Hermitbox delivers only to public addresses unless the host’s operator allows a private receiver. A caller can’t relax that allowlist.

run it yourself
$curl -fsSL https://hbx.sh | sh
or ask your agent
Install Hermitbox and set it up for me
Linux (x86_64 or aarch64), no root, no Docker. Agents can read every page: llms.txt · llms-full.txt
the floor · nothing below this line