Skip to content
PHP SDK for bunq API
Branch: develop
Clone or download
Latest commit a472a45 Feb 19, 2020
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Better punctuation. (#89) Jan 2, 2018
.idea Regenerated code based on the latest tag. Mar 22, 2019
bin Import the classes instead of using them by namspace. (#133) Apr 7, 2018
example @ 05a38a2 Added tinker as submodule for examples. (#98) Apr 7, 2018
src Version bump to 1.13.0 Feb 19, 2020
tests Implement new request signing mechanism. Removed encryption implement… Feb 19, 2020
.gitattributes Marked all files in generated dir as generated code. Sep 7, 2017
.gitignore fix gitignore [#52] Sep 26, 2017
.php_cs Added PHP-CS-Fixer config file. Aug 6, 2017
.zappr.yaml Regenerated changelog. Feb 19, 2020 add readme introduction and contribution guide Jul 31, 2017 first commit Jul 27, 2017 Updated code formatting, added missing return types Sep 9, 2019
composer.json Added PSD2 implementation, fixed common issues Sep 6, 2019
grumphp.yml Added PSD2 implementation, fixed common issues Sep 6, 2019
phpunit.xml Added PSD2 implementation, fixed common issues Sep 6, 2019

bunq PHP SDK


Hi developers!

Welcome to the bunq PHP SDK! 👨‍💻

We're very happy to introduce yet another unique product: complete banking SDKs! Now you can build even bigger and better apps and integrate them with your bank of the free! 🌈

Before you dive into this brand new SDK, please consider:

  • Checking out our new developer’s page 🙌
  • Grabbing your production API key from the bunq app or generate a Sandbox API key using Tinker 🗝
  • Visiting where you can share your creations, questions and experience 🎤

Give us your feedback, create pull requests, build your very own bunq apps and most importantly: have fun! 💪

This SDK is in beta. We cannot guarantee constant availability or stability. Thanks to your feedback we will make improvements on it.


$ composer require bunq/sdk_php


Creating an API context

In order to start making calls with the bunq API, you must first register your API key and device, and create a session. In the SDKs, we group these actions and call it "creating an API context". There are two ways to do it. One is through our interactive script, and the other is programmatically from your code.


Creating an API context using bunq-install interactive script

After installing bunq SDK into your project, run the command below from your project root folder:

$ vendor/bin/bunq-install

And then follow the steps the script offers.

Creating an API context programmatically

The context can be created by executing the following code snippet:

use bunq\Context\ApiContext;
use bunq\Util\BunqEnumApiEnvironmentType;

$environmentType = BunqEnumApiEnvironmentType::SANDBOX(); // Can also be BunqEnumApiEnvironmentType::PRODUCTION();
$apiKey = '### Your API Key ###'; // Replace with your API key
$deviceDescription = '### Your device description ###'; // Replace with your device description
$permittedIps = ['']; // List the real expected IPs of this device or leave empty to use the current IP

$apiContext = ApiContext::create(


The API context can then be saved with:

$fileName = '/path/to/save/bunq.conf/file/'; // Replace with your own secure location to store the API context details

Please note: initializing your application is a heavy task and it is recommended to do it only once per device.

After saving the context, you can restore it at any time:

$fileName = '/path/to/bunq.conf/file/';
$apiContext = ApiContext::restore($fileName);

Tip: both saving and restoring the context can be done without any arguments. In this case the context will be saved to/restored from the bunq.conf file in the same folder with your script.


It is possible to create an ApiContext as PSD2 Service Provider. Although this might seem a complex task, we wrote some helper implementations to get you started. You need to create a certificate and private key to get you started. Our sandbox environment currently accepts all certificates, if these criteria are met:

  • Up to 64 characters
  • PISP and/or AISP used in the end.

Make sure you have your unique eIDAS certificate number and certificates ready when you want to perform these tasks on our production environment.

Creating a PSD2 context is very easy:

$apiContext = ApiContext::createForPsd2(
    BunqEnumApiEnvironmentType::SANDBOX(), // Could be PRODUCTION as well.
        SecurityUtil::getCertificateFromFile($pathToCertificateInChain), // Could be one file containing chain, or multiple certificate files in array.

This context can be saved the same way as a normal ApiContext. After creating this context, create an OAuth client to get your users to grant you access. For a more detailed example, check the tinker_php repository.


You can use a proxy with the bunq PHP SDK. This option must be a string. This proxy will be used for all requests done with the context for which it was provided. You will be prompted to provide a proxy URL when using the interactive installation script.

$proxyUrl = 'socks5://localhost:1080'; // The proxy for all requests, null to disable

$apiContext = ApiContext::create(

Safety considerations

The file storing the context details (i.e. bunq.conf) is a key to your account. Anyone having access to it is able to perform any Public API actions with your account. Therefore, we recommend choosing a truly safe place to store it.

If you rather save the context in a database, you can use the fromJson() and toJson() methods.

Making API calls

There is a class for each endpoint. Each class has functions for each supported action. These actions can be create, get, update, delete and listing.

Before you can start making calls, you must ensure that you have create an ApiContext and loaded in into BunqContext as shown in the examples above.

The SDK will take care of your user Id, as this id wil never change per ApiContext. The SDK also uses your first active monetary account as primary monetary account. This is almost always the same as your billing account. This means that when you do not explicitly pass a Monetary Account ID, the SDK will use the Monetary Account ID of your billing account.

Take a look at for the full documentation.

Creating objects

BunqContext::loadApiContext($apiContext); // if it has not been loaded yet. 

    new Amount($amount, self::CURRENCY_TYPE_EUR),
    new Pointer(self::POINTER_TYPE_EMAIL, $recipient),

See tinker/BunqLib

NotificationFilters / Callbacks

Note! Due to an in internal change in the way we handle NotificationFilters (Callbacks), you should not use the default classes included in this SDK. Please make sure you make use of the associated Internal-classes. For example when you need NotificationFilterUrlUser, make use of NotificationFilterUrlUserInternal. You can use every method of these classes, except for the create() method. Always use createWithListResponse() instead.


Reading objects

To use the read method you must pass the identifier of the object to read (ID or UUID) except for the endpoints User, UserPerson, UserCompany and MonetaryAccount. The SDK will use the default IDs when none are passed. For all other endpoints you must pass the identifier.

This type of calls always returns a model.

BunqContext::loadApiContext($apiContext); // if it has not been loaded yet. 

$userCompany = UserCompany::get();


You can also retrieve this information from BunqContext, see tinker/setupCurrentUser

Updating objects

BunqContext::loadApiContext($apiContext); // if it has not been loaded yet. 


See tinker/updateBankAccountDescription

Deleting objects

BunqContext::loadApiContext($apiContext); // if it has not been loaded yet. 


Listing objects

BunqContext::loadApiContext($apiContext); // if it has not been loaded yet. 

$monetaryAccountList = MonetaryAccount::listing();

foreach ($monetaryAccountList as $monetaryAccount) {
    printf($monetaryAccount->getMonetaryAccountBank->getDescription() . PHP_EOL);

See tinker/getAllActiveBankAccount

Running Examples

If you want to play around with the SDK before you actually start implementing something awesome you can use the tinker project and adjust the code in the scripts as you please.

Running Tests

Information regarding the test cases can be found in the located in test.


The SDK can throw multiple exceptions. For an overview of these exceptions please take a look at

You can’t perform that action at this time.