Skip to main content

Overview

The Bila Go library provides convenient access to the Bila REST API from applications written in Go.

Idiomatic Go

Functional options pattern and context-aware methods throughout.

Strongly Typed

Typed request params and response structs for every endpoint.

Comprehensive

Access to all Bila API features: Accounts, Transfers, Collections, and more.

Stainless Generated

Consistently structured and always up-to-date with the latest API changes.

Installation

This library requires Go 1.22+.

Quick Start

API Classes

The SDK is organized into resources, each handling a specific domain:

Accounts

Manage your Bila wallets and check balances.

Methods

client.Accounts.Get(ctx, id) Retrieve details for a specific account.
Returns: *bila.AccountRetrieveResponse client.Accounts.List(ctx, params) List all accounts associated with your profile.
Returns: *bila.AccountListResponse client.Accounts.GetBalance(ctx, id) Check the real-time balance of an account.
Returns: *bila.AccountGetBalanceResponse

TransferRecipients

Manage payout recipients for bank and mobile money transfers.

Methods

client.TransferRecipients.Get(ctx, id) Retrieve details for a specific transfer recipient.
Returns: *bila.TransferRecipientRetrieveResponse client.TransferRecipients.List(ctx, params) List all transfer recipients.
Returns: *bila.TransferRecipientListResponse client.TransferRecipients.NewBankAccount(ctx, params) Create a new bank account transfer recipient.
Returns: *bila.TransferRecipientCreateBankAccountResponse client.TransferRecipients.NewMobileMoney(ctx, params) Create a new mobile money transfer recipient.
Returns: *bila.TransferRecipientCreateMobileMoneyResponse

Transfers

Send funds to bank accounts or mobile money wallets.

Methods

client.Transfers.Get(ctx, id) Retrieve details for a specific transfer.
Returns: *bila.TransferRetrieveResponse client.Transfers.List(ctx, params) List all transfers.
Returns: *bila.TransferListResponse client.Transfers.GetStatusByReference(ctx, reference) Get the status of a transfer by its reference.
Returns: *bila.TransferGetStatusByReferenceResponse client.Transfers.NewBankTransfer(ctx, params) Initiate a bank transfer.
Returns: *bila.TransferInitiateBankTransferResponse client.Transfers.NewMobileMoneyTransfer(ctx, params) Initiate a mobile money transfer.
Returns: *bila.TransferInitiateMobileMoneyTransferResponse

Collections

Accept mobile money payments from customers.

Methods

client.Collections.Get(ctx, id) Retrieve details for a specific collection.
Returns: *bila.CollectionRetrieveResponse client.Collections.List(ctx, params) List all collections.
Returns: *bila.CollectionListResponse client.Collections.GetStatusByReference(ctx, reference) Get the status of a collection by its reference.
Returns: *bila.CollectionGetStatusByReferenceResponse client.Collections.NewMobileMoneyCollection(ctx, params) Initiate a mobile money collection.
Returns: *bila.CollectionInitiateMobileMoneyCollectionResponse

Transactions

View and manage transaction history.

Methods

client.Transactions.Get(ctx, id) Retrieve details for a specific transaction.
Returns: *bila.TransactionRetrieveResponse client.Transactions.List(ctx, params) List all transactions.
Returns: *bila.TransactionListResponse

Webhooks

Configure endpoints to receive real-time event notifications.

Methods

client.Webhooks.New(ctx, params) Register a new webhook endpoint.
Returns: *bila.WebhookCreateResponse client.Webhooks.Update(ctx, id, params) Update an existing webhook.
Returns: *bila.WebhookUpdateResponse client.Webhooks.List(ctx) List all registered webhooks.
Returns: *bila.WebhookListResponse client.Webhooks.Deactivate(ctx, id) Deactivate a webhook.
Returns: *bila.BilaResponse client.Webhooks.GetDeliveries(ctx, id, params) Get delivery history for a specific webhook.
Returns: *bila.WebhookGetDeliveriesResponse client.Webhooks.ListEvents(ctx) List all supported webhook events.
Returns: *bila.WebhookListEventsResponse client.Webhooks.RotateSecret(ctx, id) Rotate the signing secret for a webhook.
Returns: *bila.WebhookRotateSecretResponse

Banks

Utilities for listing supported financial institutions.

Methods

client.Banks.List(ctx, params) List supported banks for a specific country.
Returns: *bila.BankListResponse

Resolve

Utilities for verifying account details.

Methods

client.Resolve.BankAccount(ctx, params) Verify the owner of a bank account.
Returns: *bila.ResolveBankAccountResponse client.Resolve.MobileMoney(ctx, params) Verify mobile money details.
Returns: *bila.ResolveMobileMoneyResponse

Error Handling

When the API returns a non-success status code, the SDK returns an error of type *bila.Error. This contains StatusCode, *http.Request, and *http.Response values, as well as the JSON of the error body.

Type Definitions

Request fields use omitzero semantics. Required primitive fields are tagged api:"required" and always serialized. Optional fields are wrapped in param.Opt[T] and set with constructors like bila.String(string), bila.Float(float64), and bila.Bool(bool).
Response structs use ordinary value types and include a JSON field with metadata about each property, including a .Valid() method to check if a field is present and non-null.

Best Practices

1

Use Environment Variables

Configure your API key via the BILA_API_KEY environment variable rather than hardcoding it. option.WithAPIKey will use this by default if no key is passed explicitly.
2

Always Pass a Context

Use context.Context to control timeouts and cancellation on every request, especially for long-running batch operations.
3

Handle Errors with errors.As

Use the errors.As pattern to unwrap *bila.Error and inspect the status code and response body for failed requests.
4

Reuse the Client

Create a single bila.NewClient() instance and reuse it across requests rather than creating a new client per call.

Next Steps

SDK Quickstart

Complete integration guide with examples

Transfers

Learn about initiating transfers

Webhooks

Set up webhook notifications

API Reference

Complete REST API documentation