Configuration
Configure Go authentication, retries, HTTP clients, and request overrides
Overview
Configuration is optional. The SDK's defaults are suitable for most integrations, so you only need this guide when you want fine-grained control over behavior such as retries, timeouts, custom HTTP clients, and per-request options.
api := client.NewClient(
option.WithToken(os.Getenv("INSION_API_KEY")),
option.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
option.WithMaxAttempts(3),
)Keep the API key on a trusted server. Never expose it in client applications, logs, or source control.
Options passed to NewClient apply to every call. The SDK retries retryable failures twice by default (three total attempts). Use option.WithoutRetries() to disable retries.
Every operation accepts trailing option.RequestOption values for one-call overrides:
result, err := api.ListRecords(
ctx,
&insion.GetAPIV1RecordsRequest{Limit: insion.Int(50)},
option.WithoutRetries(),
option.WithHTTPHeader(http.Header{"X-Request-ID": []string{"req-123"}}),
)Prefer context.WithTimeout for a call deadline. Pass a configured http.Client to control transport behavior and connection pooling.
How is this guide?