Runner overview
The Runner delivers webhooks to an application that is not reachable from the internet, such as one on a laptop or a private network. Payload Bay stays the public receiving endpoint; a small agent next to your application connects outbound, claims queued requests and replays them to a local URL. This is durable webhook delivery, not a general reverse proxy: nothing from the internet can reach your application except the requests Payload Bay has accepted and queued.
Both the Core transport and the agent are unreleased development software. The agent lives in payloadbay/runner.
Two ways to use it
| Destination | Forwarding target | |
|---|---|---|
| Used by | A route with a processing script that sends to a configured destination | A forwarding route's target group |
| Selection | The script decides | The first healthy target by priority |
| Health | None; an offline Runner makes the send time out and the script retries | Derived from Runner connectivity; an offline Runner is skipped and events queue when no target is healthy |
| Guide | Outbound private receiver Runner | Runner as a forwarding target |
Both use the same agent, the same two endpoints and the same token format; the agent cannot tell them apart. A credential is scoped to exactly one destination or one Runner target.
Run the agent
The agent needs Node 22.23.5 or newer. Configuration is environment-only; the credential, the Core URL and the local URL never appear as command-line arguments or in logs.
| Variable | Required | Default | Meaning |
|---|---|---|---|
PAYLOADBAY_URL | yes | Core HTTPS origin, no path. Plain HTTP is accepted only on loopback. | |
PAYLOADBAY_RUNNER_TARGET | yes | The local HTTP(S) URL requests are sent to. The server can never change it. | |
PAYLOADBAY_RUNNER_TOKEN | yes | The pabr_... credential from Core. | |
PAYLOADBAY_RUNNER_POLL_INTERVAL_MS | no | 2000 | Pause between idle polls (250 to 10000). |
PAYLOADBAY_RUNNER_TIMEOUT_MS | no | 15000 | Longest wait for the local receiver (1000 to 60000), also bounded by the lease. |
PAYLOADBAY_RUNNER_MAX_BACKOFF_MS | no | 10000 | Cap on the reconnect backoff (1000 to 10000). |
PAYLOADBAY_RUNNER_GRACE_MS | no | 10000 | How long a delivery in flight may finish after a stop signal (0 to 120000). |
export PAYLOADBAY_URL=https://payloadbay.example.test
export PAYLOADBAY_RUNNER_TARGET=http://localhost:3000/webhooks
export PAYLOADBAY_RUNNER_TOKEN=... # from your secret store
node src/cli.mjsThe agent fails at start-up for a malformed configuration and exits with code 1. Out-of-range values are rejected, not clamped. The poll interval and the backoff cap stop at 10000 ms because Core calls a Runner disconnected after 20 seconds without a poll (the presence window): the longest pause must stay well inside it, or a healthy Runner would flap between connected and disconnected.
Connection behavior
- Polling is the connection. The agent calls
POST /api/v1/runner/claimin a loop. An idle poll returns204and tells Core the Runner is alive. After a delivery the agent polls again at once, so a backlog drains without the idle pause. - Reconnect. A failed poll or acknowledgement is retried with exponential
backoff and full jitter, capped by
PAYLOADBAY_RUNNER_MAX_BACKOFF_MS; the delay resets after any success. During an outage a Runner target becomes unhealthy after the presence window and events use the next target or queue. - Rejected credential.
401or403(revoked, rotated, or the creator lost access) is permanent: the agent stops with exit code 1 instead of retrying. - Graceful shutdown.
SIGINTorSIGTERMstops claiming new work, lets the delivery in flight finish and report withinPAYLOADBAY_RUNNER_GRACE_MS, then exits 0. A delivery still running after the grace period is cancelled and never reported as a success; its lease expires and Core fails over or redelivers. A second signal exits immediately with code 130.
Protocol
The protocol is two bearer-authenticated JSON endpoints. Only the Runner token is accepted on them; sessions and ordinary API keys are not.
POST /api/v1/runner/claim returns 204 when nothing is waiting, or 200 with
one delivery:
| Field | Meaning |
|---|---|
id | The delivery (attempt) identifier. |
leaseToken | Secret proof of the lease, needed to acknowledge. |
leaseExpiresAt | When the lease ends. The agent refuses a delivery with under a second left. |
method, headers, bodyBase64 | The request to replay. GET and HEAD carry no body. |
idempotencyKey | A stable 64-character hexadecimal key, sent to the receiver as x-payloadbay-delivery-id. |
POST /api/v1/runner/deliveries/{id}/complete takes
{"leaseToken": "...", "result": ...} where result is
{"status": 200, "bodyBase64": "...", "contentType": "..."} (at most 64 KiB of
response) or {"networkError": "local_delivery_failed"}, and returns 204. A
second identical report is accepted; a different one, or an expired, superseded,
foreign or revoked lease, gets 409 stale_delivery or 409 delivery_result_changed and cannot finalize anything.
The agent sends the bytes to its fixed local URL, drops host and hop-by-hop
headers, never follows redirects, and treats a larger response as a failed
delivery.
Security
- Credentials are random, hashed at rest, scoped to one destination or target and revocable. The creator's permissions and any parent API-key limits are checked again on every use.
- Queued request bytes and headers are encrypted with the instance encryption key and cleared once the delivery ends or expires.
- Core never supplies the local URL, so a compromised server envelope cannot make the agent call another address.
- Delivery is at least once. If the receiver acted but the acknowledgement was lost,
the event can arrive again; deduplicate on
x-payloadbay-delivery-id.
Route request tools
Payload Bay uses one HeroUI/Monaco request composer for the published route playground and synthetic draft tests.
Outbound private receiver Runner
Core issue #18 tracks this separate product. This branch adds the Core transport; the agent is maintained in payloadbay/runner. Neither is a published release yet.