Skip to Content
Runlane
Build providers

Build an HTTP delivery adapter

Add a service-specific publisher and verifier around the shared HTTP handler.

@runlane/transport-http owns bounded HTTP ingress and the fetch handler. An exported HttpDeliveryAdapter owns the service boundary. The built-in createDirectHttpAdapter() uses signed POSTs with no broker. Service-specific publishing, authentication and response rules belong in separate adapters.

Adapter contract

MemberResponsibility
nameStable transport name.
profileCanonical TransportDriverProfile: acknowledgment durability, ordering and effective message/batch/delay limits. The provider reads it; do not maintain another capability authority.
publish(command)Existing PublishMessagesCommand to Promise<PublishMessagesResult>. Preserve body bytes and return one same-index outcome per input. Reject ambiguous batches; do not invent reliable failures for unknown network results. Honor command.signal: once it aborts, stop waiting for capacity and start no new requests.
verify({ request, body, environment })Authenticate bounded raw request bytes and extract canonical Runlane bytes. environment is supplied from the receiving runtime, not from the request body. Return HttpVerificationResultInput; do not read the request body a second time.
respond(result)Map HttpResponseResult to Response or Promise<Response> under the service's settlement rules.
start?() / close?()Own service resources. Borrowed app clients remain app-owned. Close must drain owned effects and be idempotent.

Verification returns { verified: true, body, providerMessageId? } or { verified: false, status }, where failure status is 401, 413 or 415. The provider checks httpVerificationResultSchema and copies accepted bytes into HttpVerificationResult. After authentication, the shared handler uses the canonical contracts decoder to check the envelope environment before core runs. An environment mismatch gets 401. An invalid canonical envelope is passed to respond() as a permanent Reject; direct HTTP maps it to 422. Core still owns execution validation. The outer request body must fit the shared envelope byte cap too; an adapter that wraps or expands bytes must fit that bound. Do not silently raise it for a service without defining and verifying the new boundary.

Response input is an existing DeliveryDisposition, or { type: HttpResponseType.Accepted } after core saves the run claim. For a schedule wakeup, Accepted comes once core saves the run for its fire. httpResponseResultSchema describes this union. An accepted response can arrive before task completion. Core Retry means no durable decision was reached; core Reject requires the service's permanent settlement action. If that terminal action fails, return a retry response rather than acknowledge successful disposal. Unexpected processor failures are retryable. Never serialize failure.cause, credentials, payloads or stacks.

Use the exported result types or schema-derived types. To execute an exported Standard Schema through the generic contract, call validateWithSchema() from @runlane/contracts. Do not inspect Standard Schema internals or duplicate Runlane envelope parsing.

Ownership rules

The provider validates options and adapter results, checks HTTP method/media/encoding, bounds bytes and read time, admits a bounded number of pre-claim requests, and invokes core. With explicit process lifetime, acknowledgment releases admission and maps the accepted event. Without acknowledgment it waits for the final disposition. With explicit HttpLifetimeMode.InRequest, the callback records claim ownership but keeps admission and waits for the final disposition. Client disconnects stop delivery only before the run claim, in every lifetime mode. Lifecycle-hook wakeups always use final disposition.

lifetime is required, with no default. Use the exported HttpLifetimeMode and HttpResponseType enums for lifetime modes and accepted response events.

The provider does not supply an execution semaphore after 202. Storage-backed Runlane queue limits and host execution limits own capacity. It tracks active delivery for close and optionally passes the work promise to the app's host lifetime hook. The app owns the HTTP server, deployment limits, maintenance scheduling and shutdown orchestration.

The native handler factory receives { deliver, environment } through ProviderDeliverySurface. Core supplies its own environment. The environment is required, including in direct factory calls outside core. Providers must not trust a claimed environment supplied by an unauthenticated message.

Direct protocol and future services

Adapter authors can reuse httpDeliveryHeaders for the Standard Webhooks wire names. HMAC-SHA256 signs UTF-8 id.timestamp. followed by the original body bytes. A signature is v1, plus base64; multiple signatures are separated by spaces. Secrets use whsec_ plus base64 for 24–64 random bytes. The direct adapter uses Node crypto primitives, accepts current/next verification keys, and signs with both during rotation. Exact validation, timestamp tolerance, rotation and response mapping are in HTTP options. Do not decode or reserialize the body before authentication.

A separate push service may need its own wire encoding, identity verification, response rules and capabilities. Verify its current official authentication, retention, delay, retry, size and runtime requirements before writing an adapter. Do not claim a service fits this fetch boundary without testing its ingress format and lifetime. Keep service SDKs and platform events out of core.

Verification

Run defineTransportDriverConformanceSuite from @runlane/testing for publishing. It accepts arbitrary byte messages and checks same-index outcomes, limits and immutable profiles. The direct sender uses the canonical contracts decoder to validate envelopes before network I/O, signs their original bytes, and reports invalid envelopes as non-retryable per-message failures. The receiving handler checks the authenticated environment with that same decoder.

Add real HTTP checks for authentication, byte preservation, response classes, timeouts, lost responses, bounded admission, caller byte mutation and close. Pair Local integration with durable storage tests that kill an executing process after its 202 and recover the same run through maintenance in another process. Test the host lifetime hook separately on the real deployment before claiming platform support. Local mocks do not prove a serverless host keeps work alive.

On this page