Get API Keys


dwolla-swagger-php is available on Packagist with source code available on our GitHub page.

Getting Started #

Installation #

To begin using this SDK, you will first need to download it to your machine. We use Packagist to distribute this package, which allows it to be downloaded via Composer.

$ composer require dwolla/dwollaswagger
$ composer install

To use, just require your Composer autoload.php file.


Initialization #

Before any API requests can be made, you must first determine which environment you will be using, as well as fetch the application key and secret. To fetch your application key and secret, please visit one of the following links:

Finally, you can create an instance of ApiClient after configuring the username and password values as the application key and secret that you fetched from one of the aforementioned links, respectively.

DwollaSwagger\Configuration::$username = "API_KEY";
DwollaSwagger\Configuration::$password = "API_SECRET";

# For Sandbox
$apiClient = new DwollaSwagger\ApiClient("");

# For Production
$apiClient = new DwollaSwagger\ApiClient("");


Application access tokens are used to authenticate against the API on behalf of an application. Application tokens can be used to access resources in the API that either belong to the application itself (webhooks, events, webhook-subscriptions) or the Dwolla Account that owns the application (accounts, customers, funding-sources, etc.). Application tokens are obtained by using the client_credentials OAuth grant type:

$tokensApi = new DwollaSwagger\TokensApi($apiClient);
$appToken = $tokensApi->token();

Application access tokens are short-lived: 1 hour. They do not include a refresh_token. When it expires, generate a new one using $tokensApi->token().

Making Requests #

The Dwolla client provides high-level methods for interacting with the Dwolla API.

High-Level Requests #

High-level methods make development easier by embedding information you would typically refer to Dwolla's API reference for in the SDK itself, such as endpoints, request arguments, and response deserialization. DwollaSwagger contains the API module, which allows the user to make requests, as well as models, which are data access objects that the library uses to deserialize responses.

Each model represents the different kinds of requests and responses that can be made with the Dwolla API. View the full list in the models directory.

The following API modules are available:

Setting Headers

You can pass custom headers in your requests as per the schema of the API models. Here is an example of creating a Customer with an Idempotency-Key header.

$customersApi = new DwollaSwagger\CustomersApi($apiClient);

$customer = $customersApi->create([
  "firstName" => "Jane",
  "lastName" => "Merchant",
  "email" => "",
  "type" => "receive-only",
  "businessName" => "Jane Corp llc",
  "ipAddress" => ""
], [
  "Idempotency-Key" => "51a62-3403-11e6-ac61-9e71128cae77"
$customer; # => ""

Responses #


# Retrieve an Account by ID
$accountsApi = new DwollaSwagger\AccountsApi($apiClient);
$account = $accountsApi->id("8a2cdc8d-629d-4a24-98ac-40b735229fe2");

# Retrieve a Customer by ID
$customerUrl = '';
$customersApi = new DwollaSwagger\CustomersApi($apiClient);
$customer = $customersApi->getCustomer($customerUrl);

# Create a customer funding source
$customerUrl = "";
$fsApi = new DwollaSwagger\FundingsourcesApi($apiClient);

$fundingSource = $fsApi->createCustomerFundingSource([
  "routingNumber" => "222222226",
  "accountNumber" => "123456789",
  "bankAccountType" => "checking",
  "name" => "Jane Doe’s Checking"
], $customerUrl);
$fundingSource; # => ""


You can wrap your requests in a try/catch block to handle errors.

    $new_customer = $customersApi->create([
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getResponseBody(), "\n";

Community #

2024 All Rights Reserved
Financial institutions play an important role in our network.

All funds transfers made using the Dwolla Platform are performed by a financial institution partner, and any funds held in a Dwolla Balance are held by a financial institution partner. Learn more about our financial institution partners.