API
Payload Bay serves the machine-readable OpenAPI 3.1 document at
/api/openapi.json and the interactive Scalar reference at /docs/api.
Open Account menu → API documentation, or visit the reference URL directly.
The reference renderer, fonts and specification are bundled or served locally.
The same relative URLs work on self-hosted and disposable preview installations.
No external documentation proxy is required.
The reference describes the versioned /api/v1 product API. Better Auth owns
identity/passkey endpoints under /api/auth; receiving URLs under /ingress
follow the published ingress script's method, verification and response logic.
They are separate interfaces, not assumed JSON CRUD endpoints.
Authentication and real effects
Enter a scoped API token in Scalar's Bearer authentication control. Token rights are intersected with current membership and admission; revocation, expiry and ancestor access still apply. Documentation does not grant additional rights. The browser console does not persist entered credentials in local storage.
Create personal keys in account settings; they act as your user with optionally reduced permissions. Organization, workspace and project keys stay inside their creation resource. Organization keys may additionally restrict workspaces. No instance-scoped keys can be created; the creation contract excludes that scope and the HTTP handler explicitly rejects it.
POST /api/v1/notifications/{incidentId}/snooze accepts minutes of 15, 60 or
1440. Snoozing hides that incident from your account inbox until expiry. It does
not resolve the incident, change another recipient's inbox, suppress email
subscriptions or mute a later incident. Dismissal remains a separate action.
An existing browser session can also authenticate product API calls. Mutating
cookie requests require a matching Origin and x-payloadbay-csrf: 1; the local
console supplies the CSRF header, and the browser supplies its origin normally.
The console sends requests only to this installation and rejects redirects. It
does not forward credentials through a hosted proxy or to another server.
Try request runs the actual API. It is not the effect-free script test. Use synthetic data in a disposable preview. Never connect production secrets, payloads or provider subscriptions to a shared demo.
Versions, replay and filters
Optimistic updates that require a version use If-Match: "1" with the current
quoted positive version. Membership creation has no previous version; an edit
supplies its version. Some commands, such as policy/publication updates, carry
expectedVersion in their JSON body instead. Follow the operation's contract.
Replay requires a stable idempotency-key of 1–128 characters without control
characters. Repeating the same key/input reuses the operation; changing input
under that key conflicts. A deliberate replay creates new execution history.
It does not overwrite the original request or promise exactly-once HTTP effects.
Event status filters repeat the query key, for example
state=failed_terminal&state=succeeded. Usage reads require explicit increasing
UTC from/to bounds. The window includes its start and excludes its end.
Returned counts are decimal strings to retain integer precision.
Maintaining the contract
packages/contracts/src/api-operations.ts explicitly lists the public versioned
HTTP surface. api-request-schemas.ts maps commands to the same Zod definitions
used by handlers. api-query-schemas.ts uses shared scope, pagination and usage
primitives for recognized filters. openapi.ts generates the document without
reading environment credentials, installation configuration or tenant records.
When adding an operation, update its contract and the handler together. The
owning live-api.test.ts checks the actual route exports, required path fields,
JSON commands, version/replay headers and GET filters. The API-docs browser owner
checks the local renderer and real console behavior. Register new test owners
in tests/config/inventory.json; use scoped runs during development.
JSON Schema cannot express every runtime rule, including permissions, installation state, cross-field relationships, byte budgets and immutable publication dependencies. The server still enforces them. Successful response fields depend on the caller's permissions; the document does not expose internal tables as an automatically generated public SDK. Private errors use the shared safe envelope and correlation ID.
Jobs and queues
GET /api/v1/jobs requires jobs.read at instance scope. A project-level grant
with that name does not grant instance administration. The local API reference
publishes the response schema. The dashboard entry is under Administration and
is hidden without that instance permission.
The response is an operational snapshot: up to 100 platform jobs with active work first, then due-time order, plus counts of queued/retrying processing executions that are due now, grouped by numeric priority. Paused routes and future-due retries are excluded from that backlog. The oldest queued age starts at execution creation; oldest overdue age starts at its due timestamp. Neither is provider acknowledgement latency; that unmeasured field is explicitly null. The screen currently refreshes on request, rather than claiming a live feed. Job payloads and raw upstream errors are excluded. This read-only view does not cancel, rerun or delete jobs; event replay/pause remain in their existing event/route flows.
Instance audit history
GET /api/v1/audit requires current instance-level audit.read. It returns
newest-first action metadata (actor identifier, operation, scope, resource
identifier and timestamp), never stored diffs or secret values. Project or
workspace audit rights do not grant instance administration. Use limit (1–200,
default 50) and the opaque nextCursor to page through history. Cursors preserve
timestamp precision and use the record identifier to order simultaneous actions.
The dashboard exposes the same read-only collection under Administration → Audit log.
Installation configuration and service checks
GET /api/v1/installation/settings and GET /api/v1/health require current
instance-level settings.manage. The operational projection reports
SMTP configured state, enabled OAuth provider names, registration policy,
configured executor mode and request/deadline limits. Credentials, database and
SMTP connection details are excluded. Instance customization (including future app-wide white-labeling) is hidden and
branding writes are disabled until verified enterprise licensing is available.
Installation policy and OAuth editing are documented below; SMTP and infrastructure settings remain deployment-managed. These endpoints do not rewrite deployment environment variables.
Health checks query the installation schema and probe the configured executor's
/health with a three-second deadline, a 16KiB response limit and redirects
blocked. The snapshot distinguishes ready, not-ready and unavailable executor
states, and never returns raw upstream errors. Worker health reports whether a heartbeat was recorded within 60 seconds.
SMTP health verifies a connection and authentication, without sending an email;
it does not establish mailbox delivery. Configured runc/runsc modes are
reported separately for the app and executor, without claiming host attestation.
This administrative snapshot is not an end-to-end readiness or delivery test.
Publication history supports activation and reversible archival through the same
version-checked PATCH command. Supply archived: true to archive, false to
restore, or omit it to activate. Active and latest versions cannot be archived;
an archived version must be restored before activation. Archival changes separate
metadata, never the published code or event references. Permanent deletion is not
supported: retained versions are part of recovery and explicit replay history.
Unused configuration deletion and route overview
DELETE /api/v1/endpoints/{endpointId} and
DELETE /api/v1/destinations/{destinationId} require the resource's configuration
permission, current admission and If-Match expected version. They remove unused
configuration only. Publication/event/related-setting references return409
resource_in_use, stale versions return409 version_conflict, and history is
never cascaded away. Destination removal is serialized with publication snapshot
creation through the project lock. The operator should pause a used route rather
than delete its retained history.
GET /api/v1/overview?endpointId=<uuid> applies the same current metadata and token
checks as endpoint access before returning exact route-filtered traffic buckets
and recent executions. Omitting endpointId retains the authorized all-project
view. The filter never broadens access through an instance role.
Forwarding to healthy targets
By default (mode single) a forwarding route delivers each accepted request to
exactly one currently healthy target, which is either an HTTP target or a Runner target
for a private receiver. It suits an application that runs as several instances at once, such
as a developer machine behind a tunnel plus preview deployments sharing one
database, where instances come and go. Forwarding is native: no ingress or
processing script runs, so it needs no executor.
Configuration uses the destinations.configure permission; reading uses
metadata.read.
| Operation | Purpose |
|---|---|
POST /api/v1/projects/{projectId}/target-groups | Create a group with an optional maxWaitSeconds (60 to 2,592,000, default 86,400) and mode (single, the default, or broadcast). |
GET /api/v1/projects/{projectId}/target-groups | List groups with their targets and health state. |
GET/PATCH/DELETE /api/v1/target-groups/{groupId} | Read, rename or change the time limit or mode of, and delete a group. A group that a route uses cannot be deleted. |
POST /api/v1/target-groups/{groupId}/targets | Add a target. kind is http (the default) or runner. |
PATCH/DELETE /api/v1/targets/{targetId} | Change or remove a target. A target's kind cannot change. |
POST/DELETE /api/v1/targets/{targetId}/runner | Create (or rotate) and revoke the credential of a Runner target. The token is returned once. |
POST /api/v1/projects/{projectId}/forward-endpoints | Create a route that forwards to a group. The response carries ingressKey, the stable ingress URL segment. |
An HTTP target has a deliveryUrl (where events are sent), a healthUrl (checked with
GET), optional deliveryHeaders and healthHeaders (for example an
authorization header), position (priority, lowest first), healthIntervalSeconds
(2 to 3600, default 15), healthTimeoutMs and deliveryTimeoutMs. Header values
are encrypted at rest and never returned; responses only say whether headers
exist. Changing a health check marks the target unhealthy until it passes again.
A Runner target ("kind": "runner") has no URLs and no health check to configure.
It takes name, position, enabled, deliveryHeaders, deliveryTimeoutMs and
healthIntervalSeconds, which for this kind is how long the target stays out of
rotation after a failed delivery. Its health is derived from whether its Runner is
connected; every target in GET responses carries its kind, and a Runner target
adds runner.state, runner.lastSeenAt and runner.hasCredential. See
Runner as a forwarding target.
Ingress. The request body bytes and headers are stored in one transaction
before the provider receives 200. Request protection policies still apply first.
Delivery. The first healthy target by position receives the stored body
bytes and request headers unchanged (hop-by-hop headers are dropped), so the
receiving application verifies the provider's signature itself. Payload Bay adds
x-payloadbay-event-id, x-payloadbay-delivery-id (stable for one execution) and
x-payloadbay-attempt. Delivery is at least once; receivers deduplicate by the
provider's event id.
| Outcome of a delivery | Result |
|---|---|
2xx | The event succeeds. |
Network error, timeout (for a Runner target: no Runner took the delivery, or it dropped before reporting), 3xx, 408, 425, 429 or 5xx | The target is marked unhealthy and the next healthy target is tried. |
Any other 4xx | The application refused the event. It fails as target_rejected_<status>, the target stays healthy and no other target is tried. |
Waiting. With no healthy target the event stays queued and is retried every
two to fifteen seconds without spending the execution attempt limit. It is
delivered as soon as a health check passes. When maxWaitSeconds has passed since
it was received, the execution fails with reason delivery_time_limit; the event
itself is always kept.
Inspection and replay. GET /api/v1/events/{eventId} lists every delivery
attempt with its target (name, id and target_kind), status and time, and
POST /api/v1/events/{eventId}/replay replays the event through the same group.
Broadcast mode
A group with "mode": "broadcast" delivers every accepted request to every
enabled target of the group instead of one, so one provider event can feed, for
example, a staging receiver, a production receiver and a private receiver behind a
Runner. HTTP and Runner targets can be mixed. The default single mode is
unchanged.
Each target is its own state machine for the execution, kept in a per-target row that is created the first time the execution runs (targets added later do not join an execution already started):
| Target state | Meaning |
|---|---|
pending | Not attempted yet, or waiting for the target to be healthy (an HTTP health check passing, or its Runner connected). |
retry_wait | An attempt failed; the target is retried after an exponential backoff (1 s, 2 s, 4 s, up to 60 s) and once healthy again. |
delivered | The target answered 2xx. It is never sent this execution's event again. |
failed | Final. final_reason is target_rejected_<status> (a 4xx other than 408, 425 or 429, never retried), attempts_exhausted (the execution's attempt limit, counted per target), delivery_time_limit (maxWaitSeconds passed) or target_removed. |
Targets are attempted concurrently and retried independently: a failing target never causes a target that already succeeded to receive the event again, and it does not delay them. While any target is open, the execution waits (as in single mode, without spending its processing attempts). The event-level result is aggregated from the targets:
| Event status | When |
|---|---|
delivered | Every target was delivered. The execution is succeeded. |
partial | Some targets were delivered and the rest failed. The execution is failed_terminal with reason partial_delivery. |
failed | No target was delivered. The execution is failed_terminal with reason delivery_failed. |
pending | At least one target is still open. |
GET /api/v1/events/{eventId} adds deliveryTargets (one entry per execution and
target, with state, attempts, last_status, last_error and final_reason) and
delivery (mode, status and target counts for the latest execution; null
for single-mode events). Event list items report the aggregate as deliveryState
(delivered, partial, failed or pending). Every attempt is still listed in
attempts, tagged with its target.
Replay. POST /api/v1/events/{eventId}/replay creates a new execution with
fresh per-target state, so the event is sent to every target again, including
targets that had already received it; the original execution's result is kept.
Replay of only the failed targets is not available. Delivery remains at least
once, so each receiver must deduplicate, for example by the provider's event id.
Changing a group's mode applies to executions that start afterwards; an execution
that already kept per-target state finishes in broadcast mode.
Installation configuration
GET /api/v1/installation/settings returns public operational settings and a
versioned configuration containing OAuth client IDs and secretConfigured
flags. It never returns saved client secrets. Instance settings.manage is
required for both reading and updating this configuration.
PUT /api/v1/installation/settings accepts a versioned partial settings update.
Supported policy keys are registrationPolicy, eventRetentionDays, bodyLimit,
headerLimit, ingressDeadlineMs, processingDeadlineMs, httpTimeoutMs,
maxAttempts, and otpRequestLimit; OAuth updates use settings.oauth.
Omitted policy keys keep their current values. All values are validated against
shared Zod bounds; unknown keys (including SMTP/infrastructure) are rejected.
Default retry counts apply to newly received executions. Existing executions and
replays retain their pinned retry count. Sign-in request limits apply per email
in a five-minute window. Defaults are safe constants until saved; legacy policy
environment variables do not override database values. Every web request and new
worker task reads the saved policy; retention producers recheck it each minute.
For example: {version: 0, settings: {registrationPolicy: "organization"}}.
A provider update uses {version, settings: {oauth}}.
Provider keys come from the shared oauthProviderNames catalog. Supply clientId and
clientSecret when adding an application. For the same client ID, omitting the
secret preserves its stored value. Omit a provider from oauth to disable it.
A stale version returns 409. OAuth configuration is encrypted with the existing
instance encryption key and reloaded by each web process when its revision
changes. Existing sessions remain valid. Client IDs/secrets are managed only in
the database; legacy GOOGLE_CLIENT_*/GITHUB_CLIENT_* environment settings do
not configure runtime providers.
SMTP has one separate source: deployment environment variables. Its host, credentials and sender cannot be overwritten through this API. Keep the instance encryption key outside the database and include it in the operator backup plan.
Saved TypeScript checks
GET/POST /api/v1/endpoints/{endpointId}/tests list/create named fixtures.
PUT/DELETE /api/v1/endpoints/{endpointId}/tests/{testId} update/delete them.
Definitions contain stage, synthetic request data, middleware selection,
structured expectations and optional assertionSource. They do not pin a
handler: selecting a test runs it against the current editor contents. Updates
carry the current version; a new test uses version zero. Definitions are encrypted
at rest, with at most 100 saved tests per route. Listing requires code.read and
code.test; saving/deleting additionally requires code.edit on that route's
project. A referenced route cannot be deleted while its saved tests remain.
The assertion module exports one async default function accepting
ScriptTestContext. It receives the decision kind, HTTP status/body, test and
expect. Await named checks and use toBe, toEqual, toContain or
toBeTruthy. Assertion code runs in the existing workerd executor with a
2-second deadline, no real secrets and no external fetch or managed effects.
This is an immediate regression runner, not a scheduler or arbitrary Node.js test
process.
Organization passkey policy
GET/PUT /api/v1/organizations/{organizationId}/security require that
organization's members.manage permission. Updates carry {version, requirePasskey}. An administrator must register their own passkey before
enabling the policy. Members without one receive no permissions in that
organization or its descendant workspaces/projects, but can still reach account
settings to enroll. Instance administration does not bypass the policy or grant
customer membership. The database prevents deletion of a member's last required
key; disable the policy or register another key first.
This policy requires enrollment; it is not session-level two-factor or a passkey challenge after each email login. Passkey registration requires HTTPS outside local development. It depends on the relying-party hostname and the server-side credential record. Disposable previews reset those records on clean rebuild, so an authenticator's saved credential cannot sign in after that reset.
The dashboard provider catalog matches all 36 built-in providers in the pinned Better Auth version. Provider labels are shared with sign-in. Cognito requires its AWS hosted domain, region and user-pool ID; Microsoft optionally accepts a tenant ID; PayPal and Salesforce expose their environment selection. TikTok's client key maps to the runtime's clientKey option. Custom OIDC issuers and provider-specific advanced options are not implicitly accepted as arbitrary JSON. Actual provider sign-in still requires a valid provider application and callback registration. SMTP remains environment-only.
Sign-in code throttling
POST /api/auth/email-otp/send-verification-otp has a durable per-email
30-second cooldown in addition to the configured request limit per five minutes
(default5). Concurrent requests across web instances share the same PostgreSQL
reservation. A blocked request returns HTTP429 with Retry-After in seconds and
a generic rate_limited error. Known and unknown addresses follow the same
response policy. Initial owner-code requests share the quota and cooldown.
The login UI disables code requests/resends until the deadline, retains the
countdown across same-tab reloads, and still allows verification of a received
code. Browser countdowns are feedback; server enforcement is authoritative.
Bounded diagnostic recording
Accepted events retain their full original bytes and processing job atomically before acknowledgement. Their delivery/retry/replay guarantees are unchanged.
Permissions
Payload Bay admits users to an instance separately from granting resource access. Admission by itself grants no global role.