Skip to main content
Every SDK method accepts an optional options argument that controls per-call timeouts and one-off headers. The same RequestOptions shape works for regular requests and for Kotlin Flow streams.

RequestOptions

RequestOptions is a data class with two optional fields:

Override timeout per call

Use timeoutMillis to set a shorter or longer bound for a single request.
Client.kt
The client-wide default is 30_000 milliseconds. See Client configuration for setting the default.

Inject one-off headers

Use headers to add request correlation IDs, feature flags, or override a default value once.
Client.kt

Combining options

Pass both fields together when needed:
Client.kt

Header merge order

The SDK builds the final header set in this order. Each step can overwrite the previous one:
  1. Client default headers (headers passed to the constructor)
  2. accept: application/json (regular requests) or accept: text/event-stream (streams)
  3. Per-call options.headers
  4. Authentication header (Authorization or x-api-key) from FigraniumAuthentication

Timeout and cancellation semantics

When a request exceeds the configured timeout, the underlying OkHttpClient throws an IOException (for example, java.net.SocketTimeoutException). FigraniumException extends IOException, so transport failures surface naturally through the same catch block. When the consuming coroutine is cancelled, the active Call is cancelled automatically and the flow or suspend function throws a CancellationException.
Client.kt

Stream timeouts

Streams have no default timeout. Pass options = RequestOptions(timeoutMillis = 60_000) when you want a terminal deadline. The underlying OkHttpClient cancel or timeout will surface as an IOException.
Client.kt
See Streaming for more on consuming SSE events.
Use timeoutMillis for hard deadlines on individual requests. For long-running streams, prefer cancelling the consuming coroutine scope so you can stop cleanly when your application state changes.

Client Configuration

Set client-wide defaults for timeout, headers, and auth.

Errors

Learn how FigraniumException and transport failures are surfaced.