Skip to main content
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. Create a helper that reads your base URL and API key from the environment, then passes functional options for timeout and retries:
client.go
That’s it. One import, one call, one client. From here you can create ledgers, move money, reconcile transactions, and manage your entire financial infrastructure. Pass a request struct to the service method you need. For example, create a ledger with metadata:
create-ledger.go
Per-method SDK pages in the sidebar list each call on 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:
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 to NewClient to tune behavior:
When to tune these:
  • Keep defaults if you’re making fast, local calls and want to fail fast.
  • Increase WithTimeout if you’re running large batch requests that may take a while to complete synchronously.
  • Increase WithRetry if 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 with INFO: and ERROR: prefixes. Pass a type that implements blnkgo.Logger to route these messages to your own logging system instead of stdout.

Building transaction requests

Call client.Transaction.Create and pass a blnkgo.CreateTransactionRequest struct. It has two parts:
  1. ParentTransaction holds the core transaction fields: amount, currency, source, destination, reference, and metadata.
  2. Top-level fields control how the request is processed, such as AllowOverdraft, Inflight, and ScheduledFor.
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.
Transactions are the exception. Every other resource uses a single request struct with no nesting. Pass CreateLedgerRequest to client.Ledger.Create, CreateLedgerBalanceRequest to client.LedgerBalance.Create, and so on.

JSON field names

Go struct fields use PascalCase, like MetaData 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. Per-method Go SDK pages list the Go request and response field names for each call.

Precise amounts

Transaction PreciseAmount fields use *big.Int in the Go SDK. Pass minor units with big.NewInt(...), for example big.NewInt(75000) with Precision: 100 for 750.00. Add import "math/big" at the top of your file when you use big.NewInt. You can still use Amount as a float64 when you prefer float-style values; the SDK and Core apply Precision to derive precise_amount.

Date and time fields

Fields such as DOB, 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.

Need help?

We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool. To ask questions or discuss issues, please contact us or join our Discord community.