Skip to main content

Overview

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

Named Arguments

Built for PHP 8.0+, taking advantage of named arguments for better IDE autocomplete and type safety.

Typed Models

Generated model classes for every request and response shape.

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 PHP 8.1+.

Quick Start

The SDK uses PHP 8.0+ named arguments throughout, so every call below passes its parameters by name rather than as an array - this gives you better IDE autocomplete and type checking at call sites.

API Classes

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

Accounts

Manage your Bila wallets and check balances.

Methods

$client->accounts->retrieve($id) Retrieve details for a specific account.
Returns: AccountRetrieveResponse $client->accounts->list(...) List all accounts associated with your profile.
Returns: AccountListResponse $client->accounts->getBalance($id) Check the real-time balance of an account.
Returns: AccountGetBalanceResponse

TransferRecipients

Manage payout recipients for bank and mobile money transfers.

Methods

$client->transferRecipients->retrieve($id) Retrieve details for a specific transfer recipient.
Returns: TransferRecipientRetrieveResponse $client->transferRecipients->list(...) List all transfer recipients.
Returns: TransferRecipientListResponse $client->transferRecipients->createBankAccount(...) Create a new bank account transfer recipient.
Returns: TransferRecipientCreateBankAccountResponse $client->transferRecipients->createMobileMoney(...) Create a new mobile money transfer recipient.
Returns: TransferRecipientCreateMobileMoneyResponse

Transfers

Send funds to bank accounts or mobile money wallets.

Methods

$client->transfers->retrieve($id) Retrieve details for a specific transfer.
Returns: TransferRetrieveResponse $client->transfers->list(...) List all transfers.
Returns: TransferListResponse $client->transfers->getStatusByReference($reference) Get the status of a transfer by its reference.
Returns: TransferGetStatusByReferenceResponse $client->transfers->initiateBankTransfer(...) Initiate a bank transfer.
Returns: TransferInitiateBankTransferResponse $client->transfers->initiateMobileMoneyTransfer(...) Initiate a mobile money transfer.
Returns: TransferInitiateMobileMoneyTransferResponse

Collections

Accept mobile money payments from customers.

Methods

$client->collections->retrieve($id) Retrieve details for a specific collection.
Returns: CollectionRetrieveResponse $client->collections->list(...) List all collections.
Returns: CollectionListResponse $client->collections->getStatusByReference($reference) Get the status of a collection by its reference.
Returns: CollectionGetStatusByReferenceResponse $client->collections->initiateMobileMoneyCollection(...) Initiate a mobile money collection.
Returns: CollectionInitiateMobileMoneyCollectionResponse

Transactions

View and manage transaction history.

Methods

$client->transactions->retrieve($id) Retrieve details for a specific transaction.
Returns: TransactionRetrieveResponse $client->transactions->list(...) List all transactions.
Returns: TransactionListResponse

Webhooks

Configure endpoints to receive real-time event notifications.

Methods

$client->webhooks->create(...) Register a new webhook endpoint.
Returns: WebhookCreateResponse $client->webhooks->update($id, ...) Update an existing webhook.
Returns: WebhookUpdateResponse $client->webhooks->list() List all registered webhooks.
Returns: WebhookListResponse $client->webhooks->deactivate($id) Deactivate a webhook.
Returns: WebhookDeactivateResponse $client->webhooks->getDeliveries($id, ...) Get delivery history for a specific webhook.
Returns: WebhookGetDeliveriesResponse $client->webhooks->listEvents() List all supported webhook events.
Returns: WebhookListEventsResponse $client->webhooks->rotateSecret($id) Rotate the signing secret for a webhook.
Returns: WebhookRotateSecretResponse

Banks

Utilities for listing supported financial institutions.

Methods

$client->banks->list(...) List supported banks for a specific country.
Returns: BankListResponse

Resolve

Utilities for verifying account details.

Methods

$client->resolve->bankAccount(...) Verify the owner of a bank account.
Returns: ResolveBankAccountResponse $client->resolve->mobileMoney(...) Verify mobile money details.
Returns: ResolveMobileMoneyResponse

Error Handling

When the library is unable to connect to the API, or the API returns a non-success status code, an exception extending Bila\Exceptions\APIException is thrown.

Best Practices

1

Use Environment Variables

Store your API key in an environment variable and read it with getenv('BILA_API_KEY') rather than hardcoding it in source.
2

Use Named Arguments

Pass parameters using named arguments (page: 1, perPage: 50) rather than arrays. This gives you better IDE autocomplete and catches typos at the editor level.
3

Reuse the Client

Instantiate a single Bila\Client instance per request lifecycle and reuse it across calls.
4

Handle Errors Gracefully

Catch APIStatusException separately from generic exceptions to distinguish API-level errors from connectivity issues.

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