InsionInsion
Rust

Configuration

Configure the Rust client, authentication, retries, timeouts, and per-request options.

Build ApiClient with ApiClientBuilder. ApiClientBuilder::default() starts with the SDK default environment, a 60-second timeout, three retries, and SDK-identifying headers. .build() returns Result<ApiClient, ApiError>.

use std::time::Duration;
use insion_api::prelude::*;

let client = ApiClientBuilder::new("https://api.insion.co")
    .token("<token>")
    .timeout(Duration::from_secs(30))
    .max_retries(2)
    .custom_header("X-Application", "worker")
    .user_agent("my-service/1.0")
    .build()?;

Builder options

MethodEffect
new(base_url)Starts a client with an explicit base URL.
environment(Environment)Replaces the base URL with an SDK environment URL.
token(value)Configures bearer-token authentication.
api_key(value)Configures the API-key slot exposed by the generated client.
timeout(Duration)Sets the client-wide request timeout.
max_retries(u32)Sets the client-wide retry count.
custom_header(key, value) / custom_headers(map)Adds headers to every request.
user_agent(value)Replaces the default user agent.

The builder also exposes username, password, client_id, client_secret, and oauth_credentials. Use the bearer token configuration for the Insion client shown in these guides.

One request only

Every endpoint accepts Option<RequestOptions> as its final argument. Supply None to use the client configuration or Some(...) for a one-off override:

let page = client
    .list_records(
        &ListRecordsQueryRequest::builder().limit(100).build()?,
        Some(
            RequestOptions::new()
                .timeout_seconds(15)
                .max_retries(0)
                .additional_header("X-Request-ID", request_id),
        ),
    )
    .await?;

RequestOptions supports token, api_key, max_retries, timeout_seconds, additional_header, and additional_query_param. Request options are consumed by that call and do not mutate the client. Do not use extra query parameters to replace typed filters or required model fields; use the generated builders so the SDK can encode the expected request shape.

Async execution and cancellation

The SDK methods are futures. Run them on Tokio and use your application's cancellation mechanism (for example tokio::select! with a shutdown future) when a request must stop. A timeout, transport failure, or cancellation-related failure is returned as ApiError; see Errors for matching it safely.

On this page