Optional ReadonlybodyOptional ReadonlydecodeOptional ReadonlyencodeRequest-side encoder. When set, the body goes on the wire as JSON.stringify(encode(body))
with Content-Type: application/json, and flatten is ignored. Use it when flatten can't
express the wire shape: custom date formats, snake_case keys, stripping fields. A throw inside
encode fails the request with HttpError.NetworkError, like any body that can't be serialized.
It applies to the body after beforeRequest runs, so a hook that swaps the body must keep it
a TReq.
TReq is inferred from encode. If you pass the response type explicitly
(Http.post<User>(…)), pass the request type too (Http.post<User, NewUser>(…)):
TypeScript defaults the rest to unknown, and an Encoder<NewUser> won't fit Encoder<unknown>.
Optional ReadonlyflattenWhether to flatten functype ADTs in the request body to their primitive
projections (Option → nullable, Either → right-value-or-throw-on-Left,
List → array, Try → success-value-or-throw, Map → record) before serializing.
Default true — matches the wire shape external JSON APIs expect.
Set to false to emit each ADT's canonical {_tag, value} form via
toValue() for functype-to-functype services where both ends round-trip
the tagged shape via Decoder.tagged.*.
Ignored when encode is set.
Optional ReadonlyheadersReadonlymethodOptional ReadonlyparamsQuery-string parameters appended to the URL. Merges with any query string
already present in url. See HttpQueryParams for encoding rules.
Optional ReadonlyparseOptional ReadonlysignalReadonlyurlOptional Readonlyvalidate
Either-returning response decoder. Returns
Left(DecoderError)on failure; the framework maps that toHttpError.DecodeError(cause: DecoderError). The recursiveDecoderErrortree preserves structural failure info (paths, child errors) for diagnosis and rendering.For adapters whose primary API throws (e.g. Zod's
.parse), use an adapter package (e.g.functype-zod'sDecoder.fromZod(schema)) or wrap the throwing function in a tiny custom decoder. The deprecatedvalidatefield is also still accepted for back-compat.