Configurable client options ship in v1.2.0. See the Changelog before upgrading.
Initialize the client
Your Blnk client is the single entry point to everything: ledgers, balances, transactions, reconciliation, and more. Configure it once when your app starts, then use it everywhere.client.go
create-ledger.go
client.Ledger, client.LedgerBalance, and other services.
Authentication
NewClient takes a base URL and an optional API key pointer. The SDK sends the key on every request in the X-Blnk-Key header when you pass a non-nil pointer.
How you set the API key depends on whether Core runs in secure mode:
- Secure mode
- Auth disabled
When
server.secure is enabled, pass a pointer to your API key as the second argument.Secure Blnk
Secure mode, master key, and server hardening.
Scoped API keys
Owner-scoped keys and permission limits.
Timeouts and retries
When connections fail, Core restarts, or requests hang, the SDK handles it without blocking your app. Pass functional options toNewClient to tune behavior:
| Option | Type | Default | What it does for you |
|---|---|---|---|
WithTimeout | time.Duration | 10s | How long to wait before giving up on a request. Bump this for slow operations like bulk reconciliations. |
WithRetry | int | 1 | Total attempts including the first try. 1 means no retries. 3 means up to three attempts. |
WithRetryDelay | time.Duration | 2s | Base delay between retries. Uses linear backoff. |
- Keep defaults if you’re making fast, local calls and want to fail fast.
- Increase
WithTimeoutif you’re running large batch requests that may take a while to complete synchronously. - Increase
WithRetryif you’re reading data across an unreliable network.
Retries apply to idempotent
GET requests and retryable network failures. POST, PUT, and DELETE are not retried on HTTP errors.Custom logger
By default, the SDK logs retry and transport events through a built-in logger that writes to stdout withINFO: and ERROR: prefixes.
Pass a type that implements blnkgo.Logger to route these messages to your own logging system instead of stdout.
| Level | When the SDK calls it |
|---|---|
Info | Before a retry, or when a retryable network failure will be retried |
Error | When a request returns a retryable HTTP status on a GET, or exhausts retry attempts |
Building transaction requests
Callclient.Transaction.Create and pass a blnkgo.CreateTransactionRequest struct. It has two parts:
ParentTransactionholds the core transaction fields: amount, currency, source, destination, reference, and metadata.- Top-level fields control how the request is processed, such as
AllowOverdraft,Inflight, andScheduledFor.
ParentTransaction is an embedded struct in the Go SDK, not a field in the API request body. The API expects flat JSON with fields like amount and source at the root.Do not confuse this struct with the API response field parent_transaction, which is a transaction ID linking related records such as inflight commits or split distributions.CreateLedgerRequest to client.Ledger.Create, CreateLedgerBalanceRequest to client.LedgerBalance.Create, and so on.
JSON field names
Go struct fields use PascalCase, likeMetaData and LedgerID. These map to the API’s snake_case JSON fields (meta_data, ledger_id).
You should always use the Go field names in your code.
Date and time fields
Fields such asDOB, EffectiveDate, ScheduledFor, InflightCommitDate, and historical balance timestamps use time.Time (or *time.Time). Parse ISO 8601 strings with time.Parse(time.RFC3339, "..."), for example "2024-04-22T15:28:03Z" or "2024-12-21T01:36:46+01:00", then pass the resulting value. Use a pointer when the field is optional so zero values omit from JSON.
Related docs
Quick start
Install the SDK and create your first transaction.
Error handling
Three-value returns and Core error bodies.
Changelog
Go SDK releases and version history.
Go SDK examples
Escrow, savings, cards, and reconciliation.