options argument that controls per-call timeouts and one-off headers. The same RequestOptions shape works for regular requests and for Server-Sent Events streams.
RequestOptions
RequestOptions is a Sendable struct with two optional fields:
Override timeout per call
Usetimeout to set a shorter or longer bound for a single request.
Client.swift
30 seconds. See Client configuration for setting the default.
Inject one-off headers
Useheaders to add request correlation IDs, feature flags, or override a default value once.
Client.swift
Combining options
Pass both fields together when needed:Client.swift
Header merge order
The SDK builds the final header set in this order. Each step can overwrite the previous one:- Client default headers (
headerspassed to the initializer) accept: application/json(regular requests) oraccept: text/event-stream(streams)- Per-call
options.headers - Authentication header (
Authorizationorx-api-key) fromFigraniumAuthentication
Timeout and cancellation semantics
Swift concurrency uses structured cancellation. When a request exceeds the configured timeout, or when the callingTask is cancelled, the SDK raises FigraniumError with code: "REQUEST_ABORTED".
- When a request exceeds the configured timeout, the SDK raises
FigraniumError(code: "REQUEST_ABORTED"). - When the request cannot reach the server (DNS failure, connection refused, TLS error), the SDK raises
FigraniumError(code: "NETWORK_ERROR"). - When the consuming
Taskis cancelled, the SDK catches theCancellationErrorand raisesFigraniumError(code: "REQUEST_ABORTED").
Client.swift
Stream timeouts
Streams have no default timeout. Passoptions: .init(timeout: 60) when you want a terminal deadline. The stream raises FigraniumError(code: "REQUEST_ABORTED") when the timer fires.
Client.swift